Re: gtk2.6.8, drawing_area, drawing lines, windows xp, may be a BUG



Yogesh M writes:
In windows XP: 2nd line shifts to left by 1 pixel, Gtk Version 2.6.8

Yes. This is a bug (or misfeature) that actually has been fixed only
rather recently. Upgrade to GTK+ 2.6.9.

In general GTK+ does not promise pixel-exact drawing across
platforms. Although, for simple things like solid thin horizontal and
vertical lines, it would be hard to justify not getting it exactly
right... (by "right" I mean what X11 does).

Drawing lines might seem a rather trivial operation, but getting it
right most of the time does involve understanding lots of subtle
differences between how X11 and GDI works. (Not to mention differences
between the totally obsolete 16-bit graphics subsystem of Win9x and
NT-based Windows... but nowadays I mostly just don't bother that much
considering how things might work out on Win9x.)

Here's the ChangeLog entry:

2005-06-23  Tor Lillqvist  <tml novell com>

        Improve and simplify line segment rendering on Win32, especially
        the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes
        bugs #306396 and #308413.

        * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's
        line_style, cap_style and join_style as such in the
        GdkGCWin32. Don't need to keep the pen_double_dash flag, we can
        check the line_style.

        * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets
        up the GDI pen type, style, end cap and join attributes to use
        based on the pen width, GDK line style, end cap style, and join
        style.

        For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end
        cap style, which typically are used for XOR drawing where it is
        essential that the last pixel is not drawn, use a GDI cosmetic
        pen. Only for a cosmetic pen does GDI not draw the last pixel. I
        deduced this by experimetation, the documentation is rather vague.

        For other GDK pens use a geometric GDI pen. If the width is 0 or 1
        and the GDK end cap style is GDK_CAP_BUTT, and the line style is
        GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also
        single-pixel length lines are drawn. (For sngle-pixel width lines
        roundness as such is of course irrelevant.) For dashed lines, use
        PS_ENDCAP_FLAT.

        For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE,
        respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING.

        For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to
        work better than PS_USERSTYLE. For other dashed lines, use
        PS_USERSTYLE and the dashes as set by the user (or the default
        four-pixel on-off style).

        (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes):
        Call fixup_pen() to do the pen settings after modifying some of
        the GDK GC attributes that affect pens.

        * gdk/win32/gdkdrawable-win32.c (render_line_horizontal,
        render_line_vertical, draw_segments): Check GdkGCWin32::line_style
        instead of the the removed pen_double_dash member. Don't use
        PATCOPY unconditionally in the PatBlt() call, use a raster op
        code that depends on the GC function in use.

        (draw_rectangle, draw_segments, draw_lines): Be more careful in
        deciding when to do the manual dash rendering.

        (draw_segments): Don't do any manual "last point" drawing at
        all. The above changes takes care of narrow line segments being
        drawn correctly in most cases, at least on NT-based Windows.

--tml




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]