Project

General

Profile

Bug #1803

WPainter.drawRect with PNG draws nothing if cosmetic (default) pen is used

Added by Boris Nagaev over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
Target version:
-
Start date:
04/01/2013
Due date:
% Done:

0%

Estimated time:

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

png-drawRect.cpp (1005 Bytes) png-drawRect.cpp Example. Comment out setPen to reproduce the bug. Boris Nagaev, 04/01/2013 02:45 PM
png-drawRect.cpp (1012 Bytes) png-drawRect.cpp Koen Deforche, 04/01/2013 10:14 PM
#1

Updated by Koen Deforche over 8 years ago

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).

#2

Updated by Boris Nagaev over 8 years ago

Thanks for the explanation!

Also available in: Atom PDF