Re: GTK image in drawing_area
- Posted by irv mullins <irvm at ellijay.com> Aug 08, 2005
- 599 views
Michael J. Sabal wrote: > > Before I start hacking the EuGTK library, I'm having a little difficulty with > the draw_image routine. I want to use an area of the screen where I can > display drawing primitives (lines mostly), jpeg or png images, or text. Based > on what I've read of the GTK documentation, drawing_area seems to be the > widget best suited to the task. The primitives are no problem, and I'll > tackle > the text issue a little later (requires building the pango includes that are > presently empty). When I do this: > > canvas = drawingarea() > show(win) > drawable = gtkGet(canvas,"Drawable") > gc = new_gc() > img = image("myfile.jpg") > draw_image(drawable,gc,img,0,0,0,0,320,200) > > GTK throws back a fatal exception that img is not a GTK_IMAGE via some > internal X11 call. Assume that myfile.jpg is in fact a valid image file > in the same directory as the program. > > Any suggestions, or should I start hacking? Hi Mike: First thing would be to ? img - it should be some large number, a pointer to the image. If it's 0, then there's an error reading the jpg. I've never tried adding an image to a canvas, but the GTK image is a widget, IOW, a container for a .jpg, .xpm, .gif, etc. which automagically handles displaying the file contents. You probably want to create a GDK image instead, onto which you can draw lines or pixmap data. See GDK RGB in the docs. GDK RGB isn't wrapped, but adding it should be straightforward. Irv