+ VALID_WINDOW(win, return FALSE);
+ g_return_val_if_fail(win->type == wintype_Graphics, FALSE);
+
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+ struct image_info *to_find = g_new0(struct image_info, 1);
+ struct image_info *info;
+ struct image_info *scaled_info;
+ GdkPixmap *canvas;
+
+ /* Lookup the proper resource */
+ to_find->resource_number = image;
+ to_find->scaled = TRUE; /* any image size equal or larger than requested will do */
+
+ if( !(info = image_cache_find(to_find)) ) {
+ info = load_image_in_cache(image, width, height);
+ if(info == NULL)
+ return FALSE;
+ }
+
+ gdk_threads_enter();
+
+ gtk_image_get_pixmap( GTK_IMAGE(win->widget), &canvas, NULL );
+ if(canvas == NULL) {
+ WARNING("Could not get pixmap");
+ return FALSE;
+ }
+
+ /* Scale the image if necessary */
+ if(info->width != width || info->height != height) {
+ GdkPixbuf *scaled = gdk_pixbuf_scale_simple(info->pixbuf, width, height, GDK_INTERP_BILINEAR);
+
+ /* Add the scaled image into the image cache */
+ scaled_info = g_new0(struct image_info, 1);
+ scaled_info->resource_number = info->resource_number;
+ scaled_info->width = gdk_pixbuf_get_width(scaled);
+ scaled_info->height = gdk_pixbuf_get_width(scaled);
+ scaled_info->pixbuf = scaled;
+ scaled_info->scaled = TRUE;
+ glk_data->image_cache = g_slist_prepend(glk_data->image_cache, scaled_info);
+
+ /* Continue working with the scaled version */
+ info = scaled_info;
+ }
+
+ gdk_draw_pixbuf( GDK_DRAWABLE(canvas), NULL, info->pixbuf, 0, 0, val1, val2, -1, -1, GDK_RGB_DITHER_NONE, 0, 0 );
+
+ /* Update the screen */
+ gtk_widget_queue_draw(win->widget);
+
+ gdk_threads_leave();
+