I'v tried many bitmap formats, I'v checked out printer possibility of
StretchBlt and StretchDIBits operations. This is OK. But I can not get good
result - bitmaps is not printed. :((((
I used all WinAPI functions : StretchBlt and StretchDIBits ,
StretchDIBitsToDevice, etc. - NO BITMAPS - only vector graphics!
What must I do?
Heeeeeeeeeeeeeeeeeeeeellllllllllllllllllpppppppppppppp!!!!!!!!!!!!!!!!
--
Regards,
Mark
!!!ERASE ".NO_SPAM"!!! ma...@av.krasnoyarsk.su.NO_SPAM
****** Delphi 1 and Delphi 2 version ******
procedure MemFree(Ptr: Pointer; Size: Longint);
begin
if Size < 65535 then
FreeMem(Ptr, Size)
else
GlobalFreePtr(Ptr);
end;
{Prints BitMap }
procedure DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var
Header, Bits: Pointer;
HeaderSize: Integer;
{$IfDef Win32} {Checks if using Delphi 2.0}
BitsSize : Integer;
{$Else}
BitsSize : LongInt;
{$EndIf}
begin
GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize);
Header := MemAlloc(HeaderSize);
Bits := MemAlloc(BitsSize);
try
GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^);
StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top,
DestRect.Right - DestRect.Left, DestRect.Bottom - DestRect.Top,
0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo(Header^),
DIB_RGB_COLORS, SRCCOPY);
finally
MemFree(Header, HeaderSize);
MemFree(Bits, BitsSize);
end;
end;
To call it use something like:
DrawImage(Printer.Canvas, Rect(Left, Top, Right, Bottom), MyBitmap);
This is similar to the code which is provided in the Manuals.txt file
(it's at the end of the txt file) that is installed in the Delphi directory
of D1.
****** Delphi 3 version (I haven't tested this but have been told it works)
******
procedure DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var
Header, Bits: Pointer;
HeaderSize, BitsSize: Integer;
begin
GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize);
GetMem(Header, HeaderSize);
GetMem(Bits, BitsSize);
try
GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^);
StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top,
DestRect.Right - DestRect.Left, DestRect.Bottom - DestRect.Top,
0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo(Header^),
DIB_RGB_COLORS, SRCCOPY);
finally
FreeMem(Header, HeaderSize);
FreeMem(Bits, BitsSize);
end;
end;
To call it use something like:
DrawImage(Printer.Canvas, Rect(Left, Top, Right, Bottom), MyBitmap);
Of course in either case you will heve to scale the values of Rect(Left,
Top, Right, Bottom) according to the DPI setting of the printer.
Hope this helps!
--
Rodney E Geraghty
GERA-Tech
Ottawa, Canada
ger...@ibm.net
Mark A. Malakanov <ma...@av.krasnoyarsk.su> wrote in article
<EJtqF...@sable.krasnoyarsk.su>...