Quote
> Are either of your "3000" values greater than Printer.PageWidth or
> Printer.PageHeight?
> If you still can't print your bitmap, I'd be willing to take a look at
your code
> if you can E-mail a small example that demonstrates the problem.
So, the code i tried out is attached below. The value of Pagewidth is 4646
and PageHeight is 6738. So, both of them is much greater then the 3000 i
used in the code.
The program contains a form only with one button. After starting the program
i
press the alt-printscreen to copy the form to the clipboard and then press
the
BUTTON on the form.
If i use the PrintBitmap function with 2000,2000 then the bitmap is printed
out
but when i use the 3000,3000 values (like in the code below) then only an
empty paper is printed.
What could be the problem?
Thanx in advance,
Zsolt
PROCEDURE PrintBitmap(Canvas: TCanvas; DestRect: TRect; Bitmap:
TBitmap);
VAR BitmapHeader: pBitmapInfo; BitmapImage : POINTER;
HeaderSize : DWORD; ImageSize : DWORD;
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
FreeMem(BitmapHeader); FreeMem(BitmapImage)
END
END {PrintBitmap};
procedure TForm1.Button1Click(Sender: TObject);
var
Bitmap:TBitmap;
i:Integer;
begin
with Printer do
begin
BeginDoc;
Bitmap:=TBitmap.Create;
if Clipboard.HasFormat(CF_BITMAP) then
begin
Bitmap.Assign(ClipBoard);
PrintBitmap(Canvas, Rect(200,200,3000,3000),Bitmap);
end
else
MessageDlg('Clipboard is empty',mtError,[mbOk],0);
Bitmap.Free;
EndDoc;
end;
end;