GetBitmapRowCol example for Delphi
//Add LEADDef unit to the uses.
Procedure TForm1.Button1Click(Sender: TObject);
Var
XOffset : Integer ; // Column offset of the rectangle to process
XSize : Integer ; // Pixel width of the rectangle to process
YOffset : Integer ; // Row offset of the rectangle to process
YSize : Integer ; // Pixel height of the rectangle to process
pBuf : pChar ; // Buffer to hold the row
i, n : Integer ; // Counters
hBuf : HGLOBAl ;
Begin
// Load the bitmap, at 24 bits per pixel
LeadImage.Load ('v:\images\11.bmp', 24, 0, 1);
// Specify a rectangle in the top left part of the displayed image
XOffset := LeadImage.BitmapWidth div 8 ;
XSize := LeadImage.BitmapWidth div 3;
YOffset := LeadImage.BitmapHeight div 8;
YSize := LeadImage.BitmapHeight div 3;
// Allocate the buffer
hBuf := GlobalAlloc(GMEM_MOVEABLE, XSize * 3 ) ;
pBuf := GlobalLock( hBuf );
// Invert the colors of pixels in the rectangle
for i := YOffset to (YOffset + YSize) -1 do
Begin
LeadImage.GetBitmapRowCol ( pBuf, i, XOffset, XSize * 3 );
for n :=0 to (Xsize * 3 )-1 do
( pBuf+ n) ^ := Char(Integer(((pBuf + n)^)) xor Integer($FF));
LeadImage.PutBitmapRowCol ( pBuf, i, XOffset, Xsize * 3 );
End;
// Free memory that we no longer need
GlobalFree(hBuf);
end;