[Gtk-sharp-list] Problem with Pixbuf

Sebastian scut@nb.in-berlin.de
Mon, 26 Apr 2004 09:34:31 +0800


Hi Olafur,


On Sun, Apr 25, 2004 at 06:43:29PM +0100, Olafur Arason wrote:

> I'm trying to use the pixels functionality of Pixbuf and using p = pixels
> + y * rowstride + x * n_channels to get the color, but in gtk-sharp the
> values are copied not linked. So the problem is that I have is a copy of
> pixles not the direct Pixbuf image, so to get the data into Pixbuf I have
> to have a cvs version of Pixbuf and do a pixbuf = new Pixbuf(-1, pixels,1)
> but this may be a stupit question but I'm new to c# how do you change
> byte* to byte[].
 
I use something like this (pbuf being a Gdk.Pixbuf):

	pbuf.Pixels[y * pbuf.Rowstride + x * pbuf.NChannels + 0] = 255;
	pbuf.Pixels[y * pbuf.Rowstride + x * pbuf.NChannels + 1] = 0;
	pbuf.Pixels[y * pbuf.Rowstride + x * pbuf.NChannels + 2] = 0;

to set the pixel at (x, y) to red for example.
I found that updating the pixbuf is no problem, just schedule a QueueDraw
for the Gtk.Image widget on top of it.


> Olafur Arason

ciao,
Sebastian

-- 
   |\      _,,,--,,_  ,)  scut@nb.in-berlin.de, http://segfault.net/~scut/pgp
   /,`.-'`'   -,  ;-;;'   5453 AC95 1E02 FDA7 50D2 A42D 427E 6DEF 745A 8E07
_ |,4-  ) )-,_ ) /\__________________________________________________________
~'---''(_/--' (_/-'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~