Solved

Printing Bitmaps

Posted on 1998-08-06
2
145 Views
Last Modified: 2010-04-04
I  have a problem with printer.canvas.draw and printer.canvas.stretchdraw. Sometimes when I call these two functions I get a general protection fault i GDI.exe.

Data: Delphi 1.0, win.95
0
Comment
Question by:espensen
2 Comments
 

Author Comment

by:espensen
ID: 1360082
Edited text of question
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1360083
espensen

try the following code snippet



Procedure Print_Bitmap(Bitmap : TBitmap; X, Y : Integer);
                              var
                                Info : PBitmapInfo;
                                InfoSize : Integer;
                                Image : TmemoryStream;
                                ImageSize : Longint;
                              begin
                                with Bitmap do
                                  begin
                                    GetDIBSizes(Handle, InfoSize, ImageSize);
                                    Info := MemAlloc(InfoSize);
                                    image := Tmemorystream.Create;
                                    try
                                      image.SetSize(Imagesize);
                                    try
                                      GetDIB(Handle, Palette, Info^, Image.Memory^);
                                      with Info^.bmiHeader do
                                        StretchDIBits(Printer.Canvas.Handle, X, Y, Width,
                                                              Height, 0, 0, biWidth, biHeight,
                              Image.memory, Info^,
                                                             DIB_RGB_COLORS, SRCCOPY);
                                    finally
                                      try
                                        image.free;
                                      except
                                      end;
                                    end;
                                  finally
                                    try
                                      FreeMem(Info, InfoSize);
                                    except
                                    end;
                                  end;
                                end;
                              end;

Can't remember were it's from but it may help....

Later
BoRiS

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now