Solved

Printing Bitmaps

Posted on 1998-08-06
2
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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