gdk-imlib example will not run
- From: Todd Dukes <tdukes ibmoto com>
- To: gtk <gtk-list redhat com>
- Subject: gdk-imlib example will not run
- Date: Mon, 04 Jan 1999 16:18:34 -0600
I am trying to use gdk-imlib 1.8.2 I cut the
example out of the documentation and tried to run it
with a jpg image I have. This is what I get.
$ imlibTest raptor.jpg
Gdk-ERROR **: BadMatch (invalid parameter attributes)
serial 65 error_code 8 request_code 2 minor_code 0
aborting...
Abort(coredump)
$
I will attach the source as I compiled it.
Does anyone know why this doens't work?
Todd.
--
==============================================================
| Todd Dukes E-MAIL: tdukes@ibmoto.com |
| Motorola Somerset Phone: (512) 424-8008 |
| MS OE70 |
| 6300 Bridgepoint Parkway Building #3 |
| Austin, Texas 78730 |
==============================================================
/*
To compile:<br>
cc imlibTest.c -o imlibTest `gtk-config --cflags` `imlib-config --cflags --libs-gdk` `gtk-config --libs`
*/
#include <gdk_imlib.h>
#include <gdk/gdk.h>
int main(int argc, char **argv)
{
GdkWindowAttr attr;
GdkWindow *win;
GdkPixmap *p,*m;
GdkImlibImage *im;
gint w,h;
/* Be nice and tell the user if they don't, to provide a file as an arg */
if (argc <=1)
{
printf("Usage:\n %s image_file\n",argv[0]);
exit(1);
}
/* Inititalise GDK */
gdk_init(&argc,&argv);
/* Immediately after initialising GDK, Initialise Imlib */
gdk_imlib_init();
/* Get gdk to use imlib's visual and colormap */
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
/* Load the image specified as the first argument */
im=gdk_imlib_load_image(argv[1]);
/* Suck[B the image's original width and height out of the Image structure */
w=im->rgb_width;h=im->rgb_height;
/* Set up attributes for GDK to create a Window */
attr.window_type=GDK_WINDOW_TOPLEVEL;
attr.wclass=GDK_INPUT_OUTPUT;
attr.event_mask=GDK_STRUCTURE_MASK;
attr.width=w;
attr.height=h;
/* Create a Window to display in */
win=gdk_window_new(NULL,&attr,0);
/* Render the original 24-bit Image data into a pixmap of size w * h */
gdk_imlib_render(im,w,h);
/* Extract the Image and mask pixmaps from the Image */
p=gdk_imlib_move_image(im);
/* The mask will be NULL if the image has no transparency */
m=gdk_imlib_move_mask(im);
/* Put the Image pixmap in the background of the window */
gdk_window_set_back_pixmap(win,p,0);
/* If there was a mask to the image, set the Image's mask to it */
if (m) gdk_window_shape_combine_mask(win,m,0,0);
/* Actually display the window */
gdk_window_show(win);
/* Flush the GDK buffer */
gdk_flush();
/* Event loop to handle resizes */
for(;;)
{
GdkEvent *ev;
/* Sit and wait for an event to happen */
gdk_events_pending();
/* Drag the event out of the Event queue */
ev=gdk_event_get();
/* If the event is a resize event */
if ((ev)&&(ev->type==GDK_CONFIGURE))
{
w=ev->configure.width;h=ev->configure.height;
gdk_event_free(ev);
/* Re-render the Image to the new size */
gdk_imlib_render(im,w,h);
/* Free the previous pixmap used for the window - note ONLY the pixmap is */
/* freed - the mask is marked automatically to be freed along with the */
/* pixmap. There is no need to free it as well - in fact it is advised you do */
/* not. You must use the Imlib free function because of Imlib's caching. Do */
/* not use any other free functions. You can use this function for Pixmaps */
/* not created by Imlib - and it will just go free them as expected. */
gdk_imlib_free_pixmap(p);
/* Extract the pixmap out of the Image */
p=gdk_imlib_move_image(im);
/* The mask will be NULL if the image has no transparency */
m=gdk_imlib_move_mask(im);
/* Set the new pixmap background */
gdk_window_set_back_pixmap(win,p,0);
/* If there was a mask to the image, set the Image's mask to it */
if (m) gdk_window_shape_combine_mask(win,m,0,0);
/* Clear the window to update the background change */
gdk_window_clear(win);
/* Flush GDK's buffer */
gdk_flush();
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]