gdip-pixbuf-loader r35 - in trunk: . src
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r35 - in trunk: . src
- Date: Sun, 24 Feb 2008 22:56:08 +0000 (GMT)
Author: doml
Date: Sun Feb 24 22:56:07 2008
New Revision: 35
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=35&view=rev
Log:
2008-02-24 Dom Lachowicz <domlachowicz gmail com>
* src/io-gdip-utils.c: Simple animation working; need to use a more sophisticated
animation class
Modified:
trunk/ChangeLog
trunk/src/io-gdip-utils.c
Modified: trunk/src/io-gdip-utils.c
==============================================================================
--- trunk/src/io-gdip-utils.c (original)
+++ trunk/src/io-gdip-utils.c Sun Feb 24 22:56:07 2008
@@ -27,6 +27,7 @@
#include "io-gdip-utils.h"
#include "io-gdip-native.h"
#include "io-gdip-propertytags.h"
+#include <gdk-pixbuf/gdk-pixbuf-simple-anim.h>
#define LOAD_BUFFER_SIZE 65536
@@ -457,6 +458,60 @@
return success;
}
+static gboolean
+io_gdip_bitmap_get_frame_delay (GpBitmap *bitmap, guint *delay)
+{
+ guint item_size;
+ gboolean success = FALSE;
+
+ if (bitmap == NULL || delay == NULL)
+ return FALSE;
+
+ *delay = 0;
+
+ if (0 == GdipGetPropertyItemSize ((GpImage *)bitmap, PropertyTagFrameDelay, &item_size)) {
+ PropertyItem *item;
+
+ item = (PropertyItem *)g_try_malloc (item_size);
+ if (0 == GdipGetPropertyItem ((GpImage *)bitmap, PropertyTagFrameDelay, item_size, item)) {
+ /* PropertyTagFrameDelay. Time delay, in hundredths of a second, between two frames in an animated GIF image. */
+ *delay = *((long *)item->value);
+ success = TRUE;
+ }
+
+ g_free (item);
+ }
+
+ return success;
+}
+
+static gboolean
+io_gdip_bitmap_get_n_loops (GpBitmap *bitmap, guint *loops)
+{
+ guint item_size;
+ gboolean success = FALSE;
+
+ if (bitmap == NULL || loops == NULL)
+ return FALSE;
+
+ *loops = 1;
+
+ /* PropertyTagLoopCount. 0 == infinitely */
+ if (0 == GdipGetPropertyItemSize ((GpImage *)bitmap, PropertyTagLoopCount, &item_size)) {
+ PropertyItem *item;
+
+ item = (PropertyItem *)g_try_malloc (item_size);
+ if (0 == GdipGetPropertyItem ((GpImage *)bitmap, PropertyTagLoopCount, item_size, item)) {
+ *loops = *((short *)item->value);
+ success = TRUE;
+ }
+
+ g_free (item);
+ }
+
+ return success;
+}
+
/*************************************************************************/
/*************************************************************************/
@@ -608,6 +663,7 @@
guint8 *tmp_buffer = NULL;
guint buffer_len = 0;
guint n_frames = 1, i;
+ GdkPixbufSimpleAnim *animation = NULL;
if (error)
*error = NULL;
@@ -638,8 +694,27 @@
return FALSE;
}
+ if (animation == NULL) {
+ guint n_loops, frame_delay;
+
+ io_gdip_bitmap_get_n_loops (bitmap, &n_loops);
+ io_gdip_bitmap_get_frame_delay (bitmap, &frame_delay);
+
+ (void)n_loops;
+
+ /* frame delay is in 100ths of a second */
+ if (frame_delay > 0) {
+ frame_delay = (int)((1.0 / frame_delay) * 100);
+ }
+
+ animation = gdk_pixbuf_simple_anim_new (gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ frame_delay);
+ }
+
+ gdk_pixbuf_simple_anim_add_frame (animation, pixbuf);
if (i == 0)
- emit_prepared (context, pixbuf, NULL);
+ emit_prepared (context, pixbuf, GDK_PIXBUF_ANIMATION (animation));
emit_updated (context, pixbuf);
@@ -647,67 +722,13 @@
g_object_unref (G_OBJECT (pixbuf));
}
+ if (animation != NULL)
+ g_object_unref (G_OBJECT (animation));
destroy_gdipcontext (context);
return TRUE;
}
-#if 0
-
-static gboolean
-io_gdip_bitmap_get_frame_delay (GpBitmap *bitmap, guint *delay)
-{
- guint item_size;
- gboolean success = FALSE;
-
- if (bitmap == NULL || delay == NULL)
- return FALSE;
-
- *delay = 0;
-
- if (0 == GdipGetPropertyItemSize ((GpImage *)bitmap, PropertyTagFrameDelay, &item_size)) {
- PropertyItem *item;
-
- item = (PropertyItem *)g_try_malloc (item_size);
- if (0 == GdipGetPropertyItem ((GpImage *)bitmap, PropertyTagFrameDelay, item_size, item)) {
- /* PropertyTagFrameDelay. Time delay, in hundredths of a second, between two frames in an animated GIF image. */
- *delay = *((long *)item->value);
- success = TRUE;
- }
-
- g_free (item);
- }
-
- return success;
-}
-
-static gboolean
-io_gdip_bitmap_get_n_loops (GpBitmap *bitmap, guint *loops)
-{
- guint item_size;
- gboolean success = FALSE;
-
- if (bitmap == NULL || loops == NULL)
- return FALSE;
-
- *loops = 1;
-
- /* PropertyTagLoopCount. 0 == infinitely */
- if (0 == GdipGetPropertyItemSize ((GpImage *)bitmap, PropertyTagLoopCount, &item_size)) {
- PropertyItem *item;
-
- item = (PropertyItem *)g_try_malloc (item_size);
- if (0 == GdipGetPropertyItem ((GpImage *)bitmap, PropertyTagLoopCount, item_size, item)) {
- *loops = *((short *)item->value);
- success = TRUE;
- }
-
- g_free (item);
- }
-
- return success;
-}
-
static void
gdip_animation_prepare(GdkPixbuf *pixbuf,
GdkPixbufAnimation *animation,
@@ -759,7 +780,6 @@
return animation;
}
-#endif
gboolean
gdip_save_to_file_callback (const gchar *buf,
@@ -792,10 +812,8 @@
module->stop_load = gdk_pixbuf__gdip_image_stop_load;
module->load_increment = gdk_pixbuf__gdip_image_load_increment;
-#if 0
/* this is the only way to get gtk_image_new_from_file() to load animations */
module->load_animation = gdk_pixbuf__gdip_image_load_animation;
-#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]