DrawBitmap doesn't work for printing with OnPrintPage? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

DrawBitmap doesn't work for printing with OnPrintPage?

Post by faradayent » Wed Apr 07, 2010 4:50 am

Probably overlooking something simple, but...

Is there a problem with using DrawBitmap when printing? I can't get it to display an image.

I've taken the "Printing" sample and modified it to draw bitmaps. The same bitmap displays okay on the screen from the MyCanvas::OnDraw() function, but does not appear when the code is inserted into the MyPrintout::OnPrintPage() function.

BTW, I put it in OnPrintPage rather than DrawPageOne just to simplify things.

Note that the similar DrawCheckMark (and other drawing and text things) works just fine in print preview and printing, but similarly called DrawBitmap doesn't.

Development platform is VC6 on XP using wxWidgets 2.9.
Attachments
fragment.cpp
Code fragment
(1.44 KiB) Downloaded 33 times

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Wed Apr 07, 2010 12:57 pm

I can at least tell you that I use DrawBitmap successfully when printing on wxMac and wxGTK.

Have you first verified that "if (my_sunset_jpeg.Ok())" returns true? In the snippet you posted, 'my_sunset_jpeg' seems to come out of nowehere, so we can't tell if it's correctly initialised. But the .Ok() call will tell you[/i]
"Keyboard not detected. Press F1 to continue"
-- Windows

faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Post by faradayent » Wed Apr 07, 2010 3:04 pm

Yes, Ok returns true. The same code works in the other section, just not when printing is involved.

faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Post by faradayent » Wed Apr 07, 2010 3:59 pm

Actually, DrawBitmap does work okay. I went back and cleaned up my example code and while looking at the print preview noticed a very small speck. Thought it was something on the monitor, but when I tried to clean it off realized that it was my image, shrunken down to where I could hardly see it. Thanks for your help!

Post Reply