Re: Off-by-one in gdk_draw_poly




Tomas Ogren <stric@ing.umu.se> writes:

> There's an off-by-one bug in gdk_draw_polygon ... Code-example:
> 
> GdkPoint points2[3] = {{x+2,y+2},{x+9,y+2},{x+2,x+9}};
> GdkPoint points3[3] = {{x+15+2,y+2},{x+15+9,y+2},{x+15+2,x+9}};
> /* Same, only 15 pix to the right to separate */
> 
> /* draw the polys with first filled, then nonfilled on the same place */
> gdk_draw_polygon(window, light_gc,                         TRUE, points2, 3);
> gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED],FALSE, points2, 3);
> /* then do the same, but nonfilled then filled */
> gdk_draw_polygon(window, light_gc,                        FALSE, points3, 3);
> gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED], TRUE, points3, 3);
> /* code snip from my upcoming gtk-theme */
> 
> which results in the image:
> http://www.ing.umu.se/~stric/gdkpoly.gif
> 
> The one to the right shouldn't have any white stuff, since the blue
> should cover it.. but it doesn't...
> 
> Should I accept it and work around it, or will it be fixed? (too scared
> to poke around in gdk/X myself ;P )

I don't believe you are seeing a bug in GDK (which is only a 
think wrapper around X here) or in X. Rather, the set of pixels
drawn by a filled polygon does not necessarily contain all the
pixels drawn for an unfilled polygon. The filled polygon (IIRC)
will only draw the pixels exactly on the border of the polygon
for the top and left edges, but not for the bottom and right edges.
(This is so that mulitiple adjacent polygons mate correctly)

The unfilled polygon draws the same pixels as would be seen by drawing
lines around the border. This will include all the pixels exactly on
the border, plus others beside. For 0 width lines (the default), the
exact pixels drawn will depend on the hardware. If you use 1
pixel-width lines, X defines the drawn pixels exactly, but it
will be slower. (The Xlib reference will give the details)
 
> BTW, did my bug-report on pixmap-themes really end up here? I haven't
> seen it in the archives.. now I'm subscribed here and hope that this
> report comes through...
> 
> Short on the pixmap-theme bug: http://www.ing.umu.se/~stric/gtkgimp.gif
> gdkrgb and some other special-widgets never shows up, instead you get
> whatever is behind them... (I've started a new image, so the gdkrgb
> should display a pure white color, instead I get my background pic)

It think what you are seeing is that with gtk+-themes, you are not
allowed to draw on arbitrary widgets. You are only allowed to draw on
GtkDrawingArea and GtkDrawWindow widgets.
 
> I'm using linux/x86 gimp -> 8bit sun display.

Hmmm, that would make poking around in the X source difficult.

Regards,
                                        Owen



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