如何获取指定点的颜色值?(50分)

  • 主题发起人 主题发起人 caoguangchuan
  • 开始时间 开始时间
C

caoguangchuan

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何才能获得图像中各个点的颜色值?
两个大小相同的图像,对应像素值相加,重新生成一幅图片,如何做?
 
获得图像中各个点的颜色值 Bitmap.Canvas.Pixels[x,y]

procedure TForm1.Button1Click(Sender: TObject);
var
bmp1,bmp2,bmp3:TBitmap;
i,j:integer;
begin
bmp1:=TBitmap.Create;
bmp2:=TBitmap.Create;
bmp3:=TBitmap.Create;
bmp1.LoadFromFile('c:/1.bmp');
bmp2.LoadFromFile('c:/2.bmp');
bmp3.Height:=bmp1.Height;
bmp3.Width:=bmp1.Width;
for i:=0 to bmp1.Height-1 do
for j:=0 to bmp1.Width-1 do
bmp3.Canvas.Pixels[i,j]:=bmp1.Canvas.Pixels[i,j]+bmp2.Canvas.Pixels[i,j];

bmp3.SaveToFile('c:/3.bmp');
bmp1.Free;
bmp2.Free;
bmp3.Free;
end;
速度有点慢,使用scanline可以改善速度
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部