{This is the recommended way to print images on a printer. Based on posting to borland.public.delphi.winapi by Rodney E Geraghty, 8/8/97.} PROCEDURE PrintBitmap(Canvas: TCanvas; DestRect: TRect; Bitmap: TBitmap); VAR BitmapHeader: pBitmapInfo; BitmapImage : POINTER; HeaderSize : INTEGER; {$IFDEF WIN32} ImageSize : INTEGER; {$ELSE} ImageSize : LongInt; {$ENDIF} BEGIN GetDIBSizes(Bitmap.Handle, HeaderSize, ImageSize); GetMem(BitmapHeader, HeaderSize); GetMem(BitmapImage, ImageSize); TRY GetDIB(Bitmap.Handle, Bitmap.Palette, BitmapHeader^, BitmapImage^); StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top, {Destination Origin} DestRect.Right - DestRect.Left, {Destination Width} DestRect.Bottom - DestRect.Top, {Destination Height} 0, 0, {Source Origin} Bitmap.Width, Bitmap.Height, {Source Width & Height} BitmapImage, TBitmapInfo(BitmapHeader^), DIB_RGB_COLORS, SRCCOPY) FINALLY {$IFDEF WIN32} FreeMem(BitmapHeader); FreeMem(BitmapImage) {$ELSE} FreeMem(BitmapHeader, HeaderSize); FreeMem(BitmapImage, ImageSize) {$ENDIF} END END {PrintBitmap};