Re: [gtk-list] Re: Problem adding GdkRGB access to backing pixmap in scribble-simple

> >      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,

Very possible, quite probable :-) ... I did some hacking around
on a preview and thought this would be similar enough ...

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

Just out of curiosity: Why would you want rowstride larger than width*3? What
would the benefit be?

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

Very good idea, thank you ...

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

Hmm ... unfortunateley my drawing code uses a custom buffered drawing
area and the simplest thing would be to just add the GtkRGB interface ...

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

So at least I got something right ... :-)

--> Robert

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