1

I am trying to capture some screen using GDK in c++. I managed to do this and save it to file but now I need to get all pixels values in COLORSPACE RGB. So for example black is 0 0 0 and white is 255 255 255. In python I was setting COLORSPACE.RGB in pixbuffer like that:

buf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,1,1)

And then I was drawing/saving it and I was getting pixels with rgb values using buf.get_pixels_array()

I can't manage to get rgb value in c++. I am using gdk 2.0

 GdkPixbuf *screenshot;
 GdkWindow *wind = gdk_get_default_root_window();
 GdkColormap *cm = gdk_drawable_get_colormap(wind);
 screenshot = gdk_pixbuf_get_from_drawable(NULL, wind, cm, 0, 0, 0, 0, 500, 500);

 gdk_pixbuf_save(screenshot, "ss.png", "png",NULL,NULL);
 guchar *px = gdk_pixbuf_get_pixels(screenshot);

 ofstream myfile;
 myfile.open("px.txt");
 myfile << px;
 myfile.close();

0 Answers0