Solved

Printing Bitmaps

Posted on 1998-08-06
2
144 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
Comment Utility
Edited text of question
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

13 Experts available now in Live!

Get 1:1 Help Now