Board index » delphi » printing bitmaps

printing bitmaps

How do I print a bitmap so that it fills the whole A4 paper?
I've used printer.canvas.draw(0,0,Image.picture.graphic) but the printed
image is tiny.
 

Re:printing bitmaps


Use CopyRect to expand the size of the Image.

Quote
Craig Smith wrote:
> How do I print a bitmap so that it fills the whole A4 paper?
> I've used printer.canvas.draw(0,0,Image.picture.graphic) but the printed
> image is tiny.

--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@keymaps.com

"Everywhere I go, I'm asked if I think universities stifle writers. My
opinion is that they don't stifle enough of them."

Flannery O'Connor (1925-1964)

Re:printing bitmaps


Quote
Craig Smith wrote in message <36363A12.39C22...@aol.com>...
>How do I print a bitmap so that it fills the whole A4 paper?
>I've used printer.canvas.draw(0,0,Image.picture.graphic) but the printed
>image is tiny.

The Print Option on the ShowImage Lab Report will print an image full
page in landscape orientation:

www.infomaster.net/external/efg/ImageProcessing/ShowImage.htm

Printer Demo #1 shows a comparison of using StretchDraw, StretchDIBits and
CopyRect.  In general, StretchDIBits is the way to go.

www.infomaster.net/external/efg/OtherProjects/PrinterDemo1.htm

efg
_________________________________________
efg's Computer Lab:  http://infomaster.net/external/efg

Earl F. Glynn                 E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:printing bitmaps


Hi Craig.

When printing bitmaps, you'll properly get in trouble, thats my experience.
From "I dont remember who", I once got this function, and it is GREAT !!!

Use that, and save yourself some long nights.

--
/Soeren

procedure PrintBitmap(Canvas: TCanvas; DestRect: TRect; Bitmap: TBitmap);
  VAR
    BitmapHeader:  pBitmapInfo;
    BitmapImage :  POINTER;
    HeaderSize  :  INTEGER;
{$IFDEF WIN32}
    ImageSize   :  INTEGER;
{$ELSE}
    ImageSize   :  LongInt;
    Handle      :  THandle;
{$ENDIF}
begin
  GetDIBSizes(Bitmap.Handle,HeaderSize,ImageSize);
  GetMem(BitmapHeader,HeaderSize);
{$IfDef WIN32}
  GetMem(BitmapImage,ImageSize);
{$Else}
  MHandle:=GlobalAlloc(HeapAllocFlags,ImageSize);
  BitmapImage:=GlobalLock(MHandle);
{$EndIf}
  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);
    GlobalFree(MHandle);
{$ENDIF}
  END;
END;{PrintBitmap}

Craig Smith <cr...@aol.com> skrev i artiklen <36363A12.39C22...@aol.com>...

Quote
> How do I print a bitmap so that it fills the whole A4 paper?
> I've used printer.canvas.draw(0,0,Image.picture.graphic) but the printed
> image is tiny.

Other Threads