Hi,
Apparantly there are several issues with printing a bitmap (such as the size).
The code below should solve most of them:
However, the bitmap is still printed rather small, anyone knows how to deal with this?
Thanks,
Raoul
Apparantly there are several issues with printing a bitmap (such as the size).
The code below should solve most of them:
Code:
var
Info: PBitmapInfo;
InfoSize: DWORD;
Image: Pointer;
ImageSize: DWORD;
Bits: HBITMAP;
DIBWidth, DIBHeight: LongInt;
begin
Printer.BeginDoc;
try
Canvas.Lock;
try
{ Paint bitmap to the printer }
with Printer do
begin
Bits := bmp.Handle;
GetDIBSizes(Bits, InfoSize, ImageSize);
Info := AllocMem(InfoSize);
try
Image := AllocMem(ImageSize);
try
GetDIB(Bits, 0, Info^, Image^);
with Info^.bmiHeader do
begin
DIBWidth := biWidth;
DIBHeight := biHeight;
end;
StretchDIBits(Canvas.Handle, 0, 0, DIBWidth, DIBHeight, 0, 0,
DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);
finally
FreeMem(Image, ImageSize);
end;
finally
FreeMem(Info, InfoSize);
end;
end;
finally
Canvas.Unlock;
end;
finally
Printer.EndDoc;
end;
end;
Thanks,
Raoul