Easy way to draw RGB image data on screen in GTK

I found some solutions on Google, but they all seemed long and overly complicated for what I needed, so I decided to give it a try here.

My problem is simple, I want to draw 24-bit RGB pixels on the screen.

In Qt, I would do it like this (x and y are the height and width of the image, the data points to 24-bit RGB pixels):

QImage graph((uchar *)data, x, y, QImage::Format_RGB888); QLabel *label = new QLabel(); label->setPixmap(QPixmap::fromImage(graph)); label->setFixedSize(x, y); label->show(); 

Is there a similar clean way to do this in C / GTK?

Thanks in advance.

+4
source share
1 answer

One solution to this would be to use openCV and GTK + together. First create IplImage * (its BRG is the default, and you have to convert it to RGB) and create GdkPixbuf *. From the pixel buffer, you can set the image in GtkImage *. I wrote about this on my blog: http://subinsebastien.tumblr.com/post/2839808825/opencv-gtk-and-a-day

Hope this will be helpful ...

+1
source

All Articles