[Gtk-sharp-list] Setting pixels colors of a Pixbuf

Miguel de Icaza miguel@ximian.com
05 Mar 2003 15:13:51 -0500


Hello,

> I want to store a computed picture to a file under linux using mono.
> Since System.Drawing.Bitmap is not yet implemented, I though I could use
> Gdk.Pixbuf.

Did you use this constructor:

	Pixbuf(byte [] data, bool has_alpha, int bits_per_sample, 
	      int width, int height, int rowstride,
	      Gdk.PixbufDestroyNotify destroy_fn)

> But I failed to create a Pixbuf from datas in a byte[] (mcs says that
> the corresponding constructor does not exist) and I also failed to find
> a function that will set the color of a given pixel.

The data stored in the pixbuf is layed out as 3 or 4 bytes per pixel
(depending on whether you are using RGB or RGBA formats).   And the
buffer is expected to contain a line of width pixels (the line is
actually as long as rowstride, which can be used to "pad" the line,
typically rowstride will be equal to width) and composed of height rows.

There is a bug in the current binding, so you can not extract the Pixels
value currently.

Miguel