Bug #1803
closedWPainter.drawRect with PNG draws nothing if cosmetic (default) pen is used
0%
Description
Hello!
A pen with width 0 is a cosmetic pen, and is always rendered as 1 pixel width, regardless of transformations. Cosmetic pen is used by default. If PNG back-end is used, then cosmetic pen produces nothing for drawRect.
Wt 3.2.3
Files
Updated by Koen Deforche almost 11 years ago
- File png-drawRect.cpp png-drawRect.cpp added
- Status changed from New to Rejected
- Assignee set to Koen Deforche
Hey,
I must admit, I got confused by the behavior of this test case, too. But it's not as bad as it seems.
There are two ways to get your test case to work as expected (see attached) :
- use setRenderHint(WPainter::Antialiasing) to enable aliasing. You need aliasing because you are rendering a line which overlaps two pixels (this is because of how pixels are defined in the canvas, see the visual explanation at http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WPainter.html).
- or make sure a 1 pixel width line corresponds to real device pixels by offsetting it to the half of the line.
Probably you'll want to consider both things.
Admittedly, the default behaviour of WRasterImage, without anti-aliasing, is a bit unlucky and harsh and I'm open to suggestions on how to improve the documentation (I'm not sure it's straight forward to fix the behavior unless we would want to switch on antialiasing by default (it's 2013 after all).