+ } while( (link = g_slist_next(link)) );
+
+ gdk_threads_leave();
+
+ printf("Cache miss for image %d\n", to_find->resource_number);
+ return NULL; /* No match found */
+}
+
+/**
+ * glk_image_get_info:
+ * @image: An image resource number.
+ * @width: Pointer to a location at which to store the image's width.
+ * @height: Pointer to a location at which to store the image's height.
+ *
+ * This gets information about the image resource with the given identifier. It
+ * returns %TRUE if there is such an image, and %FALSE if not. You can also pass
+ * pointers to width and height variables; if the image exists, the variables
+ * will be filled in with the width and height of the image, in pixels. (You can
+ * pass %NULL for either width or height if you don't care about that
+ * information.)
+ *
+ * <note><para>
+ * You should always use this function to measure the size of images when you
+ * are creating your display. Do this even if you created the images, and you
+ * know how big they <quote>should</quote> be. This is because images may be
+ * scaled in translating from one platform to another, or even from one
+ * machine to another. A Glk library might display all images larger than
+ * their original size, because of screen resolution or player preference.
+ * Images will be scaled proportionally, but you still need to call
+ * glk_image_get_info() to determine their absolute size.
+ * </para></note>
+ *
+ * Returns: %TRUE if @image is a valid identifier, %FALSE if not.
+ */
+glui32
+glk_image_get_info(glui32 image, glui32 *width, glui32 *height)
+{
+ struct image_info *to_find = g_new0(struct image_info, 1);
+ struct image_info *found;
+ to_find->resource_number = image;
+ to_find->scaled = FALSE; /* we want the original image size */
+
+ if( !(found = image_cache_find(to_find)) ) {
+ found = load_image_in_cache(image, 0, 0);
+ if(found == NULL)
+ return FALSE;
+ }
+
+ if(width != NULL)
+ *width = found->width;
+ if(width != NULL)
+ *height = found->height;
+ return TRUE;
+}
+
+/**
+ * glk_image_draw:
+ * @win: A graphics or text buffer window.
+ * @image: An image resource number.
+ * @val1: The x coordinate at which to draw the image (if @win is a graphics
+ * window); or, an <link linkend="chimara-imagealign-InlineUp">image
+ * alignment</link> constant (if @win is a text window).
+ * @val2: The y coordinate at which to draw the image (if @win is a graphics
+ * window); this parameter is ignored if @win is a text buffer window.
+ *
+ * This draws the given image resource in the given window. The position of the
+ * image is given by @val1 and @val2, but their meaning varies depending on what
+ * kind of window you are drawing in. See <link
+ * linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
+ * Windows</link> and <link linkend="Graphics-in-Text-Buffer-Windows">Graphics
+ * in Text Buffer Windows</link>.
+ *
+ * This function returns a flag indicating whether the drawing operation
+ * succeeded.
+ * <note><para>
+ * A %FALSE result can occur for many reasons. The image data might be
+ * corrupted; the library may not have enough memory to operate; there may be
+ * no image with the given identifier; the window might not support image
+ * display; and so on.
+ * </para></note>
+ *
+ * Returns: %TRUE if the operation succeeded, %FALSE if not.
+ */
+glui32
+glk_image_draw(winid_t win, glui32 image, glsi32 val1, glsi32 val2)
+{
+ VALID_WINDOW(win, return FALSE);
+ g_return_val_if_fail(win->type == wintype_Graphics, FALSE);
+
+ struct image_info *to_find = g_new0(struct image_info, 1);
+ struct image_info *info;
+ GdkPixmap *canvas;
+
+ /* Lookup the proper resource */
+ to_find->resource_number = image;
+ to_find->scaled = FALSE; /* we want the original image size */
+
+ if( !(info = image_cache_find(to_find)) ) {
+ info = load_image_in_cache(image, 0, 0);
+ if(info == NULL)
+ return FALSE;