Solved

Printing Bitmaps

Posted on 1998-08-06
2
149 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 96
Find and Replace Stream with 0s 8 69
Convert MS Word document to a PDF file 9 90
Delphi and Access based Enumeration 9 70
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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