반응형
function lockBitmap(Bitmap : TGPBitmap) : TBitmapData;
var
r : TGPRect;
begin
r.x := 0;
r.y := 0;
r.width := bitmap.getWidth;
r.height := bitmap.getHeight;
Bitmap.LockBits(r, ImageLockModeRead or ImageLockModeWrite,
Bitmap.GetPixelFormat, result);
end;
function Scanline(BitmapData : TBitmapData; Row : integer) : PRGBQuad;
begin
result := bitmapData.Scan0;
inc(PByte(result), Row * bitmapData.stride);
end;
procedure doStuff(Bitmap :TGPBitmap);
Var
Row, Col : integer;
theRow : PRGBQuad;
pixel : TRGBQuad;
BitmapData : TBitmapData;
begin
BitmapData := lockBitmap(Bitmap);
for Row := 0 to bitmapData.Height - 1 do
begin
theRow := Scanline(BitmapData, Row);
for Col := 0 to Bitmap.getWidth - 1 do
begin
pixel := theRow^;
..do stuff..
inc(theRow);
end;
end;
Bitmap.UnLockBits(bitmapData);
end;
var
r : TGPRect;
begin
r.x := 0;
r.y := 0;
r.width := bitmap.getWidth;
r.height := bitmap.getHeight;
Bitmap.LockBits(r, ImageLockModeRead or ImageLockModeWrite,
Bitmap.GetPixelFormat, result);
end;
function Scanline(BitmapData : TBitmapData; Row : integer) : PRGBQuad;
begin
result := bitmapData.Scan0;
inc(PByte(result), Row * bitmapData.stride);
end;
procedure doStuff(Bitmap :TGPBitmap);
Var
Row, Col : integer;
theRow : PRGBQuad;
pixel : TRGBQuad;
BitmapData : TBitmapData;
begin
BitmapData := lockBitmap(Bitmap);
for Row := 0 to bitmapData.Height - 1 do
begin
theRow := Scanline(BitmapData, Row);
for Col := 0 to Bitmap.getWidth - 1 do
begin
pixel := theRow^;
..do stuff..
inc(theRow);
end;
end;
Bitmap.UnLockBits(bitmapData);
end;
반응형