diff options
author | Jonathan Blandford <jrb@redhat.com> | 1999-10-28 14:46:46 +0000 |
---|---|---|
committer | Jonathan Blandford <jrb@src.gnome.org> | 1999-10-28 14:46:46 +0000 |
commit | 5a8b538ee199f1f9dbcd3b6f68e5753c0ef03170 (patch) | |
tree | 98fc3c19ab9c8d6d66e6abee30441ec542d4fc36 | |
parent | 53ffebed1953f888c0aaedbc9564f7c6a3cf8805 (diff) | |
download | gtk+-5a8b538ee199f1f9dbcd3b6f68e5753c0ef03170.tar.gz |
started work on the tiff non-incremental loader.
1999-10-28 Jonathan Blandford <jrb@redhat.com>
* src/io-tiff.c (image_load_increment): started work on the tiff
non-incremental loader.
* src/io-gif.c (image_load_increment): started work on the gif
incremental loader.
* src/gdk-pixbuf-io.h: Changed ModuleType to GdkPixbufModule.
-rw-r--r-- | gdk-pixbuf/ChangeLog | 10 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 8 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.h | 6 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-loader.c | 2 | ||||
-rw-r--r-- | gdk-pixbuf/io-gif.c | 74 | ||||
-rw-r--r-- | gdk-pixbuf/io-tiff.c | 61 | ||||
-rw-r--r-- | gtk/gdk-pixbuf-loader.c | 2 |
7 files changed, 150 insertions, 13 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 37e3697a0a..7759d2565f 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,13 @@ +1999-10-28 Jonathan Blandford <jrb@redhat.com> + + * src/io-tiff.c (image_load_increment): started work on the tiff + non-incremental loader. + + * src/io-gif.c (image_load_increment): started work on the gif + incremental loader. + + * src/gdk-pixbuf-io.h: Changed ModuleType to GdkPixbufModule. + 1999-10-27 Federico Mena Quintero <federico@redhat.com> * src/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): New diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index bc00617b97..16c8049e53 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -135,7 +135,7 @@ pixbuf_check_ppm (guchar *buffer, int size) } #endif -ModuleType file_formats [] = { +GdkPixbufModule file_formats [] = { { "png", pixbuf_check_png, NULL, NULL, NULL, NULL, NULL, NULL }, { "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL, NULL, NULL, NULL }, { "tiff", pixbuf_check_tiff, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -150,7 +150,7 @@ ModuleType file_formats [] = { }; static void -image_handler_load (ModuleType *image_module) +image_handler_load (GdkPixbufModule *image_module) { char *module_name; char *path; @@ -205,7 +205,7 @@ image_handler_load (ModuleType *image_module) -ModuleType * +GdkPixbufModule * gdk_pixbuf_get_module (gchar *buffer, gint size) { gint i; @@ -224,7 +224,7 @@ gdk_pixbuf_new_from_file (const char *filename) gint size; FILE *f; char buffer [128]; - ModuleType *image_module; + GdkPixbufModule *image_module; f = fopen (filename, "r"); if (!f) diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h index 74520398bc..4486adfb66 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.h +++ b/gdk-pixbuf/gdk-pixbuf-io.h @@ -30,8 +30,8 @@ typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data); -typedef struct _ModuleType ModuleType; -struct _ModuleType { +typedef struct _GdkPixbufModule GdkPixbufModule; +struct _GdkPixbufModule { char *module_name; gboolean (* format_check) (guchar *buffer, int size); GModule *module; @@ -45,5 +45,5 @@ struct _ModuleType { }; -ModuleType *gdk_pixbuf_get_module (gchar *buffer, gint size); +GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, gint size); diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c index c1fb1897fe..c7c6c5cca6 100644 --- a/gdk-pixbuf/gdk-pixbuf-loader.c +++ b/gdk-pixbuf/gdk-pixbuf-loader.c @@ -53,7 +53,7 @@ typedef struct { gboolean closed; gchar buf[128]; gint buf_offset; - ModuleType *image_module; + GdkPixbufModule *image_module; gpointer context; } GdkPixbufLoaderPrivate; diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c index 831c7ae440..38080c8e49 100644 --- a/gdk-pixbuf/io-gif.c +++ b/gdk-pixbuf/io-gif.c @@ -27,7 +27,7 @@ #include <glib.h> #include <gif_lib.h> #include "gdk-pixbuf.h" - +#include "gdk-pixbuf-io.h" /* Destroy notification function for the libart pixbuf */ @@ -44,10 +44,10 @@ image_load (FILE *f) gint fn, is_trans = FALSE; gint done = 0; gint t_color = -1; - gint w, h, i, j; + gint w = 0, h = 0, i, j; guchar *pixels, *tmpptr; GifFileType *gif; - GifRowType *rows; + GifRowType *rows = NULL; GifRecordType rec; ColorMapObject *cmap; int intoffset[] = { 0, 4, 2, 1 }; @@ -183,3 +183,71 @@ image_load (FILE *f) w, h, is_trans ? (w * 4) : (w * 3), free_buffer, NULL); } + + +/* Progressive loader */ +typedef struct _GifData GifData; +struct _GifData +{ + ModulePreparedNotifyFunc *func; + gpointer user_data; + + GifFileType *gif_handle; + guchar *buf; + guint ptr; + gint size; +}; + +gpointer +image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data) +{ + GifData *context; + + context = g_new (GifData, 1); + context->func = func; + context->user_data = user_data; + context->buf = NULL; + context->gif_handle = NULL; + return context; +} + +int +myInputFunc (GifFileType *type, GifByteType *byte, int length) +{ + GifData *context; + + context = (GifData *) type->UserData; + g_print ("in myInputFunc\nSize requested is %d\n", length); + + if (length > context->size - context->ptr) { + memcpy (byte, context->buf + context->ptr, context->size - context->ptr); + return context->size - context->ptr; + } + + memcpy (byte, context->buf + context->ptr, length); + return length; +} + +void +image_stop_load (gpointer context) +{ + g_free ((GifData *) context); +} + +gboolean +image_load_increment (gpointer data, guchar *buf, guint size) +{ + GifData *context = (GifData *) data; + + g_print ("in load_increment: %d\n", size); + context->buf = g_realloc (context->buf, size); + context->ptr = 0; + context->size = size; + memcpy (context->buf, buf, size); + + if ((context->gif_handle == NULL) && (context->size > 20)) + context->gif_handle = DGifOpen (context, myInputFunc); + + g_print ("width = %d, height = %d\n", context->gif_handle->SWidth, context->gif_handle->SHeight); + return FALSE; +} diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c index d93dd1e509..b21dad4aec 100644 --- a/gdk-pixbuf/io-tiff.c +++ b/gdk-pixbuf/io-tiff.c @@ -25,9 +25,11 @@ /* Following code (almost) blatantly ripped from Imlib */ #include <config.h> -#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <tiffio.h> #include "gdk-pixbuf.h" +#include "gdk-pixbuf-io.h" @@ -99,3 +101,60 @@ image_load (FILE *f) w, h, w * 4, free_buffer, NULL); } + +/* Progressive loader */ + +/* + * Tiff loading progressively cannot be done. We write it to a file, then load + * the file when it's done. + */ + +typedef struct _TiffData TiffData; +struct _TiffData +{ + ModulePreparedNotifyFunc *func; + gpointer user_data; + + FILE *file; +}; + +gpointer +image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data) +{ + TiffData *context; + gint fd; + char template[21]; + + context = g_new (TiffData, 1); + context->func = func; + context->user_data = user_data; + + strncpy (template, "/tmp/temp-tiffXXXXXX", strlen ("/tmp/temp-tiffXXXXXX")); + fd = mkstemp (template); + g_print ("fd=%d\n", fd); + context->file = fdopen (fd, "w"); + if (context->file == NULL) + g_print ("it's null\n"); + else + g_print ("it's not null\n"); + return context; +} + +void +image_stop_load (gpointer data) +{ + TiffData *context = (TiffData*) data; + fclose (context->file); +/* unlink (context->file);*/ + g_free ((TiffData *) context); +} + +gboolean +image_load_increment (gpointer data, guchar *buf, guint size) +{ + TiffData *context = (TiffData *) data; + + g_assert (context->file != NULL); + fwrite (buf, sizeof (guchar), size, context->file); + return TRUE; +} diff --git a/gtk/gdk-pixbuf-loader.c b/gtk/gdk-pixbuf-loader.c index c1fb1897fe..c7c6c5cca6 100644 --- a/gtk/gdk-pixbuf-loader.c +++ b/gtk/gdk-pixbuf-loader.c @@ -53,7 +53,7 @@ typedef struct { gboolean closed; gchar buf[128]; gint buf_offset; - ModuleType *image_module; + GdkPixbufModule *image_module; gpointer context; } GdkPixbufLoaderPrivate; |