[ wxwindows-Bugs-1739456 ] GraphicsContext should be consistent about pixel centers

SourceForge.net noreply at sourceforge.net
Wed Oct 10 08:14:37 PDT 2007


Bugs item #1739456, was opened at 2007-06-18 21:35
Message generated for change (Comment added) made by kevinwatters
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1739456&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Common
Group: Platform specific
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Billy B (baxissimo)
Assigned to: Stefan Csomor (csomor)
Summary: GraphicsContext should be consistent about pixel centers

Initial Comment:
It seems that the GraphicsContext's on GTK2 and Windows don't agree about the coordinates of a pixel center, or at least the locations of the corners of a filled rect.

For instance if you do

   gc.SetPen(wxTRANSPARENT_PEN)
   gc.SetBrush(wxBLACK_BRUSH)
   gc.DrawRectangle(5,5,5,5)

on Windows you get a fuzzy-edged rectangle, but on GTK it's crisp.

Likewise,
   gc.DrawRectangle(4.5,4.5, 5,5)

Gives you fuzzy edges on Windows but sharp edges on GTK.

I think these sorts of fairly major platform differences have to be paved over by the GraphicsContext API.  Platform independent code is the goal of wxWidgets after all.



----------------------------------------------------------------------

Comment By: Kevin Watters (kevinwatters)
Date: 2007-10-10 10:14

Message:
Logged In: YES 
user_id=1731802
Originator: NO

I added a one-liner patch using csomor's suggestion for
Graphics::SetPixelOffsetMode--see patch #1810897 for the patch.

----------------------------------------------------------------------

Comment By: Billy B (baxissimo)
Date: 2007-06-21 19:41

Message:
Logged In: YES 
user_id=821871
Originator: YES

Yes, by all means.  If GDI+ has such a mode, most certainly it should be
turned on to be consistent with other platforms.
About making a user-visible option - does the option do anything different
than a simple gc.Translate(0.5,0.5)?  If not then I don't see any need for
it.

----------------------------------------------------------------------

Comment By: Stefan Csomor (csomor)
Date: 2007-06-21 14:00

Message:
Logged In: YES 
user_id=81467
Originator: NO

I tend to agree, so we would switch the PixelOffsetMode on the GDIPlus to
PixelOffsetModeHalf, like this we have just a defined behaviour, which IMHO
is simple to deal than to offer a switch exposed in the wxGraphicsContext
which have both options

Thanks,

Stefan

----------------------------------------------------------------------

Comment By: Billy B (baxissimo)
Date: 2007-06-18 22:46

Message:
Logged In: YES 
user_id=821871
Originator: YES

> gc.DrawRectangle(4.5,4.5, 5,5)
> Gives you fuzzy edges on Windows but sharp edges on GTK.

Sorry, I meant the other way around.  This version is sharp for MSW fuzzy
for GTK.

wxGraphicsContext should document which convention it's going with, and
stick to it on all platforms.  I personally like the pixel centers on the
1/2's convention.  Then a filled rect covering exactly one pixel is
DrawRect(0,0,1,1).  Strokes are kind of odd anyway you handle them in a
fractional coordinate world, so might as well make the fill rule easy to
deal with.  Fills are also more fundamental in path-based graphics.  You
can create a fill that is identical to any given stroke, but not generally
vice versa.

So my vote is to declare wxGTK's way correct and the behavior of wxMSW a
bug.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1739456&group_id=9863




More information about the wx-dev mailing list