Drawing a point in a pixbuf.



Hi,

I have a function that tries to draw a point at (x,y) in a GdkPixbuf
and I am using the formula:
 
                 guchar *p;
                 p = pixels + y * rowstride + x * n_channels;
 
to locate the point in the pixbuf. I have used gdk_functions to get the
'pixels' value which is start of the pixbuf-values and the rowstride,
n_channels and has_alpha. I checked the value of 'rowstride' and it was 
2800 for my pixbuf and 'n_channels' was 4.
However when I try to set the rgb-values for the pixel (x,y) I get a
segmentation fault...? The code I have used is:
                  
               ->  *p++ = 0xff;
                     *p++ = 0;
                     *p++ = 0xfc;
                     *p      =  has_alpha;

The segmentation fault occurs at the arrow. I guess you can use
gdk_draw_point() instead but I want to make the code a bit faster
and use a function that can draw many pixels at once in a single function.

magnus m



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