Re: [gtk-list] Problem adding GdkRGB access to backing pixmap inscribble-simple
- From: Havoc Pennington <rhp zirx pair com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Problem adding GdkRGB access to backing pixmap inscribble-simple
- Date: Sun, 9 May 1999 14:29:21 -0400 (EDT)
On Sun, 9 May 1999 robert_gasch@peoplesoft.com wrote:
> gdk_draw_rgb_image (pixmap,
> widget->style->black_gc,
> 0, y-10, 200, 1, GDK_RGB_DITHER_NONE, buf, 200*3);
I think you're a bit confused on the structure of the RGB buffer, so
you're causing GdkRGB to go way off the end of it.
The buffer should have 3 bytes per pixel; so at least width*height*3
bytes. The "rowstride" is the distance between row starts, in bytes; so
for example, if you have row 0 at index 0, and row 1 is at index 37, then
your rowstride is 37-0=37. The rowstride can be larger than width*3, in
which case some bytes will be skipped (only width*3 bytes per row are
needed). If rowstride is larger than width, you need an accordingly larger
buffer.
A tip: when I'm writing code that writes to an RGB buffer in a complicated
way, I find it helpful to put magic "padding" bytes at the end, set them
all to some value, then after drawing read them back and assert that the
value is unchanged. This detects buffer overwrites and you can even print
a message showing the location of the overwrite. My development
GnomeCanvas is hacked to do this.
> Unfortunateley, this dumps core. gdk_draw_rgb_image expects a
> drawable but doesn't seem to like being passed a pixmap. Is
> drawing to a pixmap via GdkRGB functions possible at all?
Should work with a pixmap (although, if you draw everything with GdkRGB
then the RGB buffer is already playing backing store so the pixmap is just
a waste).
> draw_point is very slow and I'd like to use something
> faster ...
>
GdkRGB is definitely the correct thing to use if you want to dump a bunch
of arbitrary pixels to the screen, good call on that...
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]