我在背景为绿色的图片的canvas上画了一条红色的线,那么这条线所覆盖的象素的颜色会改变吗?
假如以前的canvas.pixels=clgreen,那么这个象素点被红色直线画上之后,他的颜色值能是clRed吗?在线等!
假如以前的canvas.pixels=clgreen,那么这个象素点被红色直线画上之后,他的颜色值能是clRed吗?在线等!
解决方案 »
- 根据TLB文件调用另外一个EXE文件,总不成功.
- DBGrid 中数据导出到Excel 问题
- 把汉字怎么转换成十六进制的数?
- 求不规则图形CAD排料(用DELHPI编程演示)算法
- 面对突如其来的感情难题,兄弟姐妹们,silverwonder有些话想说,同时散分给亲爱的你们!
- 问个弱智问题,给大家送点分。
- delphi 报错问题
- 在OleContainer1中嵌入一个有数据的excel文件如C;\aa.xls,在OleContainer1中双击并修改这个文件,如何保存这个修改的excel文件?
- 谁用过tuxedo,有delphi的tuxedo控间吗?
- 在DBGrid中如何判断未存入表中的数据不能为空?
- 有没有人看到书店还有这本书:《可视化OpenGL程序设计》, 出版社:清华 作者:费广正等
- 5个简单问题,1个20分,谢谢大家帮忙
http://www.nutricia.com.cn/vote.asp?id=736
谢谢
您说的pen.mode指的是什么,pen.mode在什么情况下才能改变覆盖的象素的颜色呢?请帮忙
再请教您个问题:我在一幅底色为绿色的图片上,用红色画笔圈定了一个区域,我想把这个红色画笔圈定的边界作为剪裁的边界,请问我怎样才能确定每一行上的红色边界点呢,也就是说,怎么写代码才能表示这个红色点就是边界点呢?我不知道算法,请您帮我想想啊,感激不尽了。
您的儿子很帅哟,呵呵!投票成功!
pmBlack Always black
pmWhite Always white
pmNop Unchanged
pmNot Inverse of canvas background color
pmCopy Pen color specified in Color property
pmNotCopy Inverse of pen color
pmMergePenNot Combination of pen color and inverse of canvas background
pmMaskPenNot Combination of colors common to both pen and inverse of canvas background.
pmMergeNotPen Combination of canvas background color and inverse of pen color
pmMaskNotPen Combination of colors common to both canvas background and inverse of pen
.......
很多,看 TPen 的 mode 的帮助.
if canvas.pixels[x,y]:=clred then
//用循环走完全部的x,y组合,把红色点找出来。
http://blog.csdn.net/whbo
这里应该还有关于图形的几句代码,参考下
怎样用区域的知识啊,教教我吧!
我的意思把红色点以外的象素颜色都变成白色,内部点保留,代码该怎么写呀? 可否助我一臂之力,万分感激
//就好像在图上点了一下,所有与该点相同的区域都会变成 (theColor)设定的颜色。//theCanvas: 画板。 theColor: 填充的颜色. thePoint: 基点。procedure FillFlood(const theCanvas: TCanvas; const theColor: TColor;
const thePoint: TPoint);
begin
theCanvas.Brush.Color := theColor; // //最重要的函数。 API函数.
ExtFloodFill(theCanvas.Handle, thePoint.X, thePoint.Y,
GetPixel(theCanvas.Handle, thePoint.X, thePoint.Y), 4);
theCanvas.Brush.Style := bsClear;
theCanvas.Pixels[thePoint.X, thePoint.Y] := theColor;end;//看你的悟性了
我就想按照你说的方法做,可是我这个红色点怎么找到呢,我发现在一幅图片上画红色的线,可显示出来的却不是红色线,您说,是不是线下面的象素颜色和当前红色混合成别的颜色了呢,画线的颜色能改变它下面象素的颜色值吗?在线等待指导!还有,如果用scanline方法,那当前象素的颜色该怎样表示呢,如果象素颜色是红色的话,
p:prgbtriple;
p[x].rgbtblue=
p[x].rgbtgreen=
p[x].rgbtred= 等号右边的值该怎样赋值呢,黑色用0表示,白色用255表示,那红色用什么表示,红色还分好多种呢,该写什么呀。如果不这样赋值,该怎样呢!快指导指导我吧!
对象素操作很慢的,每次运行都结束不了操作,能和扫描线方法结合着用吗?等待指导!
设置 TPen 的 mode 为 pmCopy。你想采用种子填充方法吧,那需要用到堆栈的,递归。我劝你还是采用 ExtFloodFill 来填充整个区域吧。
种子填充需要对每个象素操作。
procedure FillColors(FBitmap: TBitmap; FWidth, FHeight, Xs,
Ys: integer; OldColor, NewColor: Byte);
type
stackfield = record
xl, xr, y: integer;
end;
var
i, X, Xl, Xr, p_Xl, p_Xr, signed_Y: integer;
P: PByteArray;
stack: array of stackfield;
procedure set_stack_empty();
begin setlength(stack, 1);
stack[0].y := 0;
end;
function stack_not_empty(): boolean;
begin
if stack[0].y = 0 then
result := false
else
result := true;
end;
procedure push(xl, xr, yd: integer);
begin
stack[0].y := stack[0].y + 1;
if stack[0].y > (length(stack) - 1) then
setlength(stack, length(stack) + 1);
stack[stack[0].y].xl := xl;
stack[stack[0].y].xr := xr;
stack[stack[0].y].y := yd
end;
procedure pop(var xl: integer; var xr: integer; var yd: integer);
begin
if stack[0].y > 0 then
begin
xl := stack[stack[0].y].xl;
xr := stack[stack[0].y].xr;
yd := stack[stack[0].y].y;
stack[0].y := stack[0].y - 1;
setlength(stack, length(stack) - 1);
end;
end;
begin
//Fwidth,FHeight为位图的宽度和高度
set_stack_empty; //////////
P := fbitmap.ScanLine[Ys];
i := Xs;
if P[i] = Newcolor then
exit;
while (P[i] = OldColor) do
begin
P[i] := NewColor;
i := i + 1;
if i = fbitmap.Width then
break;
end;
Xr := i - 1;
i := Xs - 1;
while (P[i] = OldColor) do
begin
P[i] := NewColor;
i := i - 1;
if i = -1 then
break;
end;
Xl := i + 1;
if ys > 0 then
push(Xl, Xr, -(Ys - 1));
if ys < fbitmap.height - 1 then
push(Xl, Xr, (Ys + 1));
while stack_not_empty do
begin
pop(p_Xl, p_Xr, signed_Y);
//y:=abs(signed_Y);
P := fbitmap.scanline[abs(signed_y)];
if (P[p_Xl] = OldColor) then //xl处是oldcolor时
if p_xl > 0 then
begin
x := p_Xl - 1; //,xl非边界,否则将会出边界
while (P[x] = OldColor) do
begin
P[x] := NewColor;
x := x - 1;
if x = -1 then
break;
end;
Xl := x + 1;
x := p_Xl;
end
else
begin
xl := 0; // 左边界已是0 时,新的xl自然取0
x := p_xl;
end
else
begin
x := p_Xl;
// 否则xl处非oldcolor,xl的左邻点不为olodcolor时,xl的右邻点可能为oldcolor时 ,向右找xl
if ((x > 0) and (p[x - 1] <> oldcolor)) or (x = 0) then
begin
while (p[x] <> OldColor) do
begin
x := x + 1;
if x = fbitmap.Width then
begin
x := x + 1;
break;
end;
end;
xl := x;
end
else if p_xl > 0 then
//否则xl 的左邻点是oldcolor时,先考虑左边,向左找xl
begin
x := p_Xl - 1;
while (P[x] = OldColor) do
begin
P[x] := NewColor;
x := x - 1;
if x = -1 then
break;
end;
Xl := x + 1;
x := p_Xl;
end
else
begin
xl := 0;
x := p_xl;
end end;
while x <= (p_Xr + 1) do
begin
while (p[x] = OldColor) do
begin
p[x] := NewColor;
x := x + 1;
if x = fbitmap.Width then
begin
break;
end;
end;
Xr := x - 1;
if (abs(signed_y - 1) <= (fbitmap.Height - 1)) and (abs(signed_y - 1)
>= 0) then
begin
if (Xl <= p_Xl - 1) then
push(xl, p_Xl - 1, -(signed_y - 1));
if (Xr >= p_Xr + 1) then
push(p_xr + 1, xr, -(signed_y - 1));
end;
if (abs(signed_y + 1) <= (fbitmap.Height - 1)) and (abs(signed_y + 1)
>= 0) then
push(Xl, Xr, signed_y + 1);
if x = fbitmap.Width then
x := X + 1;
if x <= (fbitmap.width - 1) then
while (x <= p_xr + 1) and (p[x] <> OldColor) do
begin
x := x + 1;
if x = fbitmap.Width then
begin
x := x + 1;
BREAK;
end; end;
Xl := x;
end;
end;
// Fbitmap.invalidate;
end;
p[x].rgbtblue= clBlue //蓝色
p[x].rgbtgreen= clGreen //绿色
p[x].rgbtred= clRed //红色
设置 TPen 的 mode 为 pmCopy。
self.Canvas.Pen.Mode := pmCopy;
我受益匪浅,可要是把边界外的区域剪裁掉,该怎么做呢,还能用种子填充了吗?请指示!!!
关于把边界外的区域剪裁掉:利用区域的相关知识。Rgn SelectClipRgn