Felix wrote:
Hello All,
I am a new GTK user, and I would be grateful if someone will find time to help me.
Lets say that I receive an iplImage (opencv parameter), and my goal is to show this image in a GTK/GDK window/widget.
I have written this code, but I am not able to see the image inside a widget (nothing appears on the screen):
GtkWidget* convertOpenCv2Gtk (IplImage* srcImage)
{
GtkWidget* gtkImg = NULL;
GdkPixbuf* gtkPixbuf = NULL;
IplImage* dstImage = NULL;
/** Creating the destionation image */
dstImage = cvCreateImage( cvSize(srcImage->width,srcImage->height), IPL_DEPTH_8U, 3);
/** Converting the format of the picture from BGR to RGB */
cvCvtColor ( srcImage, dstImage, CV_BGR2RGB );
/** Creates a new GdkPixbuf out of in-memory image data */
gtkPixbuf = gdk_pixbuf_new_from_data ( (guchar*)dstImage->imageData,
GDK_COLORSPACE_RGB,
FALSE,
dstImage->depth,
dstImage->width,
dstImage->height,
(dstImage->widthStep),
NULL,
NULL
);
/** Create new GtkImage displaying pixbuf */
gtkImg = gtk_image_new_from_pixbuf ( gtkPixbuf );
return gtkImg;
}
In the main function I am just trying to show the received widget:
gtkWindow = convertOpenCv2Gtk ( iplImage );
gtk_widget_queue_draw ( gtkWindow );
Why it doesn´t works?
What wrong have I done?
What parts are missing?
Thanks in advance to you all :),
Felix.
Hello All,
Please do not answer all together, I can´t read so many answers ;).
Please remember, that you also have started once...
Thanks again,
Felix.