Firemonkey Bitmap 设定像素颜色 Pixel

VCL 和 Firemonkey 的 Bitmap 处理像素的方式不相同,下例为将图片内不是「白色」的像素全部改成「黑色」:

procedure TForm1.Button1Click(Sender: TObject);
var x, y: Integer;
    vBitMapData: TBitmapData;
begin
     if Image1.Bitmap.Map(TMapAccess.maWrite, vBitMapData) then
     begin
          for x:=0 to Image1.Bitmap.Width - 1 do
              for y:=0 to Image1.Bitmap.Height - 1 do
                  if vBitMapData.GetPixel(x, y) <> TAlphaColors.White then
                     vBitMapData.SetPixel(x, y, TAlphaColors.Black);
          Image1.Bitmap.Unmap(vBitMapData);
     end;
end;

 

posted @ 2014-11-03 13:34  龟山Aone  阅读(1402)  评论(0编辑  收藏  举报