Hello everyone! I'm fairly new to using gtk and c and I have a question regarding changing the color of pixels. So I have an image file I read it and do some calculations using the pixel data which I access doing this:
pixbuf = gtk_image_get_pixbuf(img);
n_channels = gdk_pixbuf_get_n_channels(pixbuf);
Then I position myself on the image pixel using this
/*p is also a guchar
x and y are the image coordinates*/
p = pixs + y * rowstride + x * n_channels;
and then I change the color of a pixel using this
For example, afterwards I just write the modified image to hard drive
The strange thing is that the image appears on my Desktop and the pixels are colored like it should but my program crashes.
If I comment this part out:
Then the program never crashes.
So my question is, is it fine the way I am coloring the pixels or should I do it another way? Apparently the program doesn't like the way I color the pixels since that's the only part that causes it to crash.