+/**
+ * grits_tile_load_pixels:
+ * @tile: the tile to load data into
+ * @pixels: buffered pixel data
+ * @width: width of the pixel buffer (in pixels)
+ * @height: height of the pixel buffer (in pixels)
+ * @alpha: TRUE if the pixel data contains an alpha channel
+ *
+ * Load tile data from an in memory pixel buffer.
+ *
+ * This function is thread safe and my be called from outside the main thread.
+ *
+ * Ownership of the pixel buffer is passed to the tile, it should not be freed
+ * or modified after calling this function.
+ *
+ * Returns: TRUE if the image was loaded successfully
+ */
+gboolean grits_tile_load_pixels(GritsTile *tile, guchar *pixels,
+ gint width, gint height, gint alpha)
+{
+ g_debug("GritsTile: load_pixels - %p -> %p (%dx%d:%d)",
+ tile, pixels, width, height, alpha);
+
+ /* Copy pixbuf data for callback */
+ tile->width = width;
+ tile->height = height;
+ tile->alpha = alpha;
+ tile->pixels = pixels;
+
+ /* Queue OpenGL texture load/draw */
+ grits_object_queue_draw(GRITS_OBJECT(tile));
+ return TRUE;
+}
+
+/**
+ * grits_tile_load_file:
+ * @tile: the tile to load data into
+ * @file: path to an image file to load
+ *
+ * Load tile data from a GdkPixbuf
+ * This function is thread safe and my be called from outside the main thread.
+ *
+ * Returns: TRUE if the image was loaded successfully
+ */
+gboolean grits_tile_load_pixbuf(GritsTile *tile, GdkPixbuf *pixbuf)
+{
+ g_debug("GritsTile: load_pixbuf %p -> %p", tile, pixbuf);
+
+ /* Copy pixbuf data for callback */
+ tile->pixbuf = g_object_ref(pixbuf);
+ tile->width = gdk_pixbuf_get_width(pixbuf);
+ tile->height = gdk_pixbuf_get_height(pixbuf);
+ tile->alpha = gdk_pixbuf_get_has_alpha(pixbuf);
+ tile->pixels = gdk_pixbuf_get_pixels(pixbuf);
+
+ /* Queue OpenGL texture load/draw */
+ grits_object_queue_draw(GRITS_OBJECT(tile));
+
+ return TRUE;
+}
+
+/**
+ * grits_tile_load_file:
+ * @tile: the tile to load data into
+ * @file: path to an image file to load
+ *
+ * Load tile data from an image file
+ * This function is thread safe and my be called from outside the main thread.
+ *
+ * Returns: TRUE if the image was loaded successfully
+ */
+gboolean grits_tile_load_file(GritsTile *tile, const gchar *file)
+{
+ g_debug("GritsTile: load_file %p -> %s", tile, file);
+
+ /* Load pixbuf */
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+ if (!pixbuf)
+ return FALSE;
+
+ /* Copy pixbuf data for callback */
+ tile->pixbuf = pixbuf;
+ tile->width = gdk_pixbuf_get_width(pixbuf);
+ tile->height = gdk_pixbuf_get_height(pixbuf);
+ tile->alpha = gdk_pixbuf_get_has_alpha(pixbuf);
+ tile->pixels = gdk_pixbuf_get_pixels(pixbuf);
+
+ /* Queue OpenGL texture load/draw */
+ grits_object_queue_draw(GRITS_OBJECT(tile));
+
+ return TRUE;
+}
+