怎么获取一幅Bmp图像的每个像素点的坐标与颜色数?(200分)

  • 主题发起人 sunslove
  • 开始时间
S

sunslove

Unregistered / Unconfirmed
GUEST, unregistred user!
请各位帮帮忙。
怎么在一幅Bmp图像中获取每一个点的坐标和颜色的Rgb值,然后把颜色值处理后
写入另一个BMP文件中?
 
bmp.canvas.pixel[x,y](低速)或bmp.scanline(高速)
 
用scanline啊,比如bmp的反色:
procedure TForm1.anticolorClick(Sender: TObject);
var
p :pByteArray;
x,y :Integer;
Bmp :TBitmap;
begin
Bmp :=TBitmap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
Bmp.PixelFormat :=pf24Bit;
for y:=0 to Bmp.Height-1 do
begin
p:=Bmp.scanline[y];
for x:=0 to Bmp.Width-1 do
begin
// Gray:=Round(p[x*3+2]*0.3+p[x*3+1]*0.59+p[x*3]*0.11);
p[x*3]:=not p[x*3];
p[x*3+1]:=not p[x*3+1];
p[x*3+2]:=not p[x*3+2];
end;
end;
Image1.Picture.Bitmap.Assign(Bmp);
Bmp.Free;
end;
 
多人接受答案了。
 
谢谢各位!!!!
 
顶部