[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Printing Bitmaps

Posted on 1998-08-06
2
Medium Priority
?
158 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

656 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