comparison gtk/dw.c @ 244:68158098a092

Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 19 Feb 2003 07:41:50 +0000
parents 00d2b1bcf036
children 11baf43efbc2
comparison
equal deleted inserted replaced
243:3c1e39905f2f 244:68158098a092
5060 */ 5060 */
5061 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename) 5061 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename)
5062 { 5062 {
5063 int _locked_by_me = FALSE; 5063 int _locked_by_me = FALSE;
5064 HPIXMAP pixmap; 5064 HPIXMAP pixmap;
5065 #ifndef USE_IMLIB
5065 GdkBitmap *bitmap = NULL; 5066 GdkBitmap *bitmap = NULL;
5067 #endif
5066 #if GTK_MAJOR_VERSION > 1 5068 #if GTK_MAJOR_VERSION > 1
5067 GdkPixbuf *pixbuf; 5069 GdkPixbuf *pixbuf;
5070 #elif defined(USE_IMLIB)
5071 GdkImlibImage *image;
5068 #endif 5072 #endif
5069 char *file = alloca(strlen(filename) + 5); 5073 char *file = alloca(strlen(filename) + 5);
5070 5074
5071 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) 5075 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
5072 return NULL; 5076 return NULL;
5092 pixmap->width = gdk_pixbuf_get_width(pixbuf); 5096 pixmap->width = gdk_pixbuf_get_width(pixbuf);
5093 pixmap->height = gdk_pixbuf_get_height(pixbuf); 5097 pixmap->height = gdk_pixbuf_get_height(pixbuf);
5094 5098
5095 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1); 5099 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
5096 g_object_unref(pixbuf); 5100 g_object_unref(pixbuf);
5101 #elif defined(USE_IMLIB)
5102 image = gdk_imlib_load_image(file);
5103 pixmap->pixmap = gdk_imlib_copy_image(image);
5104
5105 pixmap->width = image->rgb_width;
5106 pixmap->height = image->rgb_height;
5107
5108 gdk_imlib_destroy_image(image);
5109 #else
5110 pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
5097 #endif 5111 #endif
5098 pixmap->handle = handle; 5112 pixmap->handle = handle;
5099 DW_MUTEX_UNLOCK; 5113 DW_MUTEX_UNLOCK;
5100 return pixmap; 5114 return pixmap;
5101 } 5115 }