Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Printing bitmaps revisited

Brooks_Van_Horn
New Contributor I
661 Views

I've followed all my resources including using stretchblt and I can't get a bitmap to print. I've included three files. The first is entitled test2.pdf and is an example of my screen. The second is called error.pdf is is the exception thrown by printing. The third file is the source code I used to try to print the graphic part sans the dialog of the screen. I followed the C++ example at http://www.dreamincode.net/forums/topic/261009-bitmap-printing-tutorial-in-c-win32/ but have not been successful. I think there is a difference between a bitmap in a file and a screen capture bitmap but I haven't found out the differences. Please look at my code and see what you think I'm doing wrong. Everythin is done in X64 Fortran with the latest iFort 2016 and MSVS 2013.

Thanks in advance,

Brooks

PS,

If you think you need the whole code I can zip it but it is pretty large.

0 Kudos
1 Solution
IanH
Honored Contributor II
661 Views

Why are you printing after calling BeginPaint?  Is this printing code actually being called from within WM_PAINT processing?  Why does your procedure take an object of type T_PAINTSTRUCT?  The context of this code doesn't make sense.

I don't see the memory DC being created anywhere in the code, prior to the call to SelectObject on line 103.

(Why are you trying to print a screen grab of something which your application just drew?  Your application knows how to draw what you see on the screen - just get it to draw that stuff to the printer instead - rather than drawing to a DC from BeginPaint, draw to the DC out of the result of calling PrintDlg.  The quality of the printed output will be vastly superior.)

 

View solution in original post

0 Kudos
3 Replies
IanH
Honored Contributor II
662 Views

Why are you printing after calling BeginPaint?  Is this printing code actually being called from within WM_PAINT processing?  Why does your procedure take an object of type T_PAINTSTRUCT?  The context of this code doesn't make sense.

I don't see the memory DC being created anywhere in the code, prior to the call to SelectObject on line 103.

(Why are you trying to print a screen grab of something which your application just drew?  Your application knows how to draw what you see on the screen - just get it to draw that stuff to the printer instead - rather than drawing to a DC from BeginPaint, draw to the DC out of the result of calling PrintDlg.  The quality of the printed output will be vastly superior.)

 

0 Kudos
Brooks_Van_Horn
New Contributor I
661 Views

Actually, I did originally draw to the printer DC but the results were terrible. My 36 point font was only readable with a magnifying glass. The lines that appear on the screen were so fine I could hardly tell they were there. Thanks on the hdcmem goof. I'll fix that and see if it works.

Thanks

Brooks

0 Kudos
Brooks_Van_Horn
New Contributor I
661 Views

IanH,

That did it. I am now printing and it's great! Thanks very much.

Brooks

0 Kudos
Reply