Using Dephi for image processing can be a variety of methods, the most commonly used should be tbitmap, it provides easy access to the image, combined with canvas can be drawn line, draw a circle, image copy and other operations. However, in order to obtain a higher speed, we hope to read and write directly to the image buffer in a large number of image processing operations. Consult the Dephi Help manual did not find a direct access to the entire image buffer function, but the provided Scanline property can get the specified row image data pointer, compared to our request, first look at the scanline description:
Provides indexed access to each line of pixels.
property ScanLine[Row: Integer]: Pointer;
Description
ScanLine is used only with DIBs (Device Independent Bitmaps) for image editing tools that do low-level pixel work.
Let's look at the relationship between Scanline[0], Scanline[1]:
procedure TForm1.Button1Click(Sender: TObject);
var
BitMap: TBitmap;
S: String;
begin
BitMap := TBitmap.Create;
try
BitMap.PixelFormat := pf24bit; //24位色,每像素点3个字节
BitMap.Width := 1000;
BitMap.Height := 2;
FmtStr(S, 'ScanLine[0]:%8x'#13'ScanLine[1]:%8x'#13'ScanLine[1]-ScanLine[0]:%d'
, [Integer(BitMap.ScanLine[0]), Integer(BitMap.ScanLine[1])
, Integer(BitMap.ScanLine[1]) - Integer(BitMap.ScanLine[0])]);
MessageBox(Handle, PChar(S), 'ScanLine', MB_OK);
finally
if Assigned(BitMap) then FreeAndNil(BitMap);
end;
end;
The following are the results of the operation:
ScanLine[0]: E90BB8
ScanLine[1]: E90000
ScanLine[1]-ScanLine[0]:-3000