Opened 13 years ago

Closed 11 months ago

Last modified 11 months ago

#379 closed defect (fixed)

wxPrintDC::DrawIcon() renders nothing

Reported by: jeff_s Owned by:
Priority: normal Milestone:
Component: wxMSW Version: dev-latest
Keywords: wxMSWDCImpl printing wxIcon icon printer DC Cc: jeff_s
Blocked By: Blocking:
Patch: yes

Description

Using wxMSW / wxPython 2.3.2, I have found a problem with getting a bitmap printed.
DrawRectangle, DrawText, etc, all work fine. DrawBitmap works in print preview mode; when
actually printing, it seems to work only when the (color) printer is in fast/draft mode. When the
printer is in normal/quality mode, or in *any* case on a (b&w) laser printer, nothing is displayed
where the bitmap should be. (But a rectangle drawn to the same dimensions displays fine.) This
behavior is consistent across different color (HP Deskjet 870, HP Deskjet 990) and laser (HP
LaserJet 5si, HP Laserjet 8150) printers.

However, the wxPython Demo does not have this problem--its printing sample renders bitmaps
properly on all four printers, in both draft and normal modes. I can't identify any significant
difference between the demo code and my own code, except for the image source -- I'm loading
wxImages from JPG files, then converting to wxBitmaps, while the demo is loading a wxBitmap from
saved XPM data -- but I would expect that once the wxBitmap is created, then the original source
shouldn't matter.

Attachments (1)

icon-to-bitmap.patch download (1.6 KB) - added by awi 11 months ago.
Drawing icon as bitmap on printer DC.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by wojdyr

  • Component set to wxMSW
  • Owner set to vadz

comment:2 Changed 7 years ago by vadz

  • Status changed from new to infoneeded_new

Is this still the case with remotely recent wx versions?

comment:3 Changed 3 years ago by oneeyeman

Just wondering if anybody have the printer mentioned in the description to test this with?

comment:4 follow-up: Changed 2 years ago by ericj

  • Status changed from infoneeded_new to new

I don't have any of the specific printers, but i use a B/W laser printer.

Bitmaps drawn with wxDC::DrawBitmap() appear, however in the "printing" sample, the icon drawn with DrawIcon() does not appear. This can also be seen when printing to a PDF file.

comment:5 in reply to: ↑ 4 Changed 2 years ago by oneeyeman

Eric,

Replying to ericj:

I don't have any of the specific printers, but i use a B/W laser printer.

Bitmaps drawn with wxDC::DrawBitmap() appear, however in the "printing" sample, the icon drawn with DrawIcon() does not appear. This can also be seen when printing to a PDF file.

Do you have a second printer? Maybe there is something wrong with the driver?

comment:6 Changed 2 years ago by ericj

I don't have a 2nd physical printer. But the printer driver for my laser printer and the pdf printer driver are totally different.

comment:7 follow-up: Changed 2 years ago by vadz

  • Status changed from new to confirmed
  • Summary changed from wxPrintDC.DrawBitmap() renders nothing to wxPrintDC::DrawIcon() renders nothing

Actually I see this myself in the printing sample with PDFCreator printer. DrawIcon() doesn't work, DrawBitmap() does. We probably need to override the former in wxPrinterDC to call the latter...

comment:8 Changed 2 years ago by vadz

  • Owner vadz deleted
  • Status changed from confirmed to new

comment:9 Changed 2 years ago by vadz

  • Status changed from new to confirmed

comment:10 in reply to: ↑ 7 Changed 2 years ago by oneeyeman

Vadim,
Replying to vadz:

Actually I see this myself in the printing sample with PDFCreator printer. DrawIcon() doesn't work, DrawBitmap() does. We probably need to override the former in wxPrinterDC to call the latter...

Just tried to find out what is going on.
The code draws everything textual, then dc.DrawIcon() calls wxMSWDCImpl::DoDrawIcon(), which calls Win32 function ::DrawIconEx().
And so I just don't understand what is happening...

Changed 11 months ago by awi

Drawing icon as bitmap on printer DC.

comment:11 Changed 11 months ago by awi

  • Keywords wxMSWDCImpl wxIcon icon printer DC added
  • Patch set
  • Version set to dev-latest

It seems that DrawIcon(Ex) API doesn't work for printer DCs because DrawIcon(Ex) requires DCs supporting SRCINVERT raster operations.
See: http://support.microsoft.com/KB/110796
Printer DCs are write-only and XOR operation cannot be performed.
For printer DCs we need to convert icon to bitmap (printed with SRCCOPY ROP).

Patch attached.

comment:12 Changed 11 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [75729]) Fix wxPrinterDC::DrawIcon() in wxMSW.

Make DrawIcon() work when printing: it previously didn't, as we used
::DrawIconEx() Windows function which wasn't supported when printing.
Work around this by using DrawBitmap() if necessary.

Closes #379.

comment:13 Changed 11 months ago by VZ

(In [75736]) Fix wxPrinterDC::DrawIcon() in wxMSW.

Make DrawIcon() work when printing: it previously didn't, as we used
::DrawIconEx() Windows function which wasn't supported when printing.
Work around this by using DrawBitmap() if necessary.

Closes #379.

Note: See TracTickets for help on using tickets.