2001-05-07 15:58:47 +00:00
|
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
1999-10-20 21:20:49 +00:00
|
|
|
|
/* GdkPixbuf library - GIF image loader
|
1999-06-29 06:07:14 +00:00
|
|
|
|
*
|
1999-06-30 15:28:43 +00:00
|
|
|
|
* Copyright (C) 1999 Mark Crichton
|
1999-10-20 21:20:49 +00:00
|
|
|
|
* Copyright (C) 1999 The Free Software Foundation
|
|
|
|
|
*
|
1999-10-30 22:04:27 +00:00
|
|
|
|
* Authors: Jonathan Blandford <jrb@redhat.com>
|
|
|
|
|
* Adapted from the gimp gif filter written by Adam Moss <adam@gimp.org>
|
1999-11-03 22:27:59 +00:00
|
|
|
|
* Gimp work based on earlier work.
|
1999-10-30 22:04:27 +00:00
|
|
|
|
* Permission to relicense under the LGPL obtained.
|
1999-06-30 15:28:43 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-06-30 15:28:43 +00:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1999-06-30 15:28:43 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-10-20 21:20:49 +00:00
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1999-06-29 06:07:14 +00:00
|
|
|
|
*/
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
/* This loader is very hairy code.
|
|
|
|
|
*
|
|
|
|
|
* The main loop was not designed for incremental loading, so when it was hacked
|
|
|
|
|
* in it got a bit messy. Basicly, every function is written to expect a failed
|
|
|
|
|
* read_gif, and lets you call it again assuming that the bytes are there.
|
|
|
|
|
*
|
|
|
|
|
* Return vals.
|
|
|
|
|
* Unless otherwise specified, these are the return vals for most functions:
|
|
|
|
|
*
|
|
|
|
|
* 0 -> success
|
|
|
|
|
* -1 -> more bytes needed.
|
|
|
|
|
* -2 -> failure; abort the load
|
|
|
|
|
* -3 -> control needs to be passed back to the main loop
|
|
|
|
|
* \_ (most of the time returning 0 will get this, but not always)
|
2000-01-07 18:29:13 +00:00
|
|
|
|
*
|
1999-11-03 23:22:27 +00:00
|
|
|
|
* >1 -> for functions that get a guchar, the char will be returned.
|
|
|
|
|
*
|
|
|
|
|
* -jrb (11/03/1999)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If you have any images that crash this code, please, please let me know and
|
|
|
|
|
* send them to me.
|
|
|
|
|
* <jrb@redhat.com>
|
|
|
|
|
*/
|
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
|
|
|
|
|
|
1999-06-29 06:07:14 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <stdio.h>
|
1999-10-30 19:28:53 +00:00
|
|
|
|
#include <string.h>
|
2001-05-07 15:58:47 +00:00
|
|
|
|
#include <errno.h>
|
2000-04-11 07:03:25 +00:00
|
|
|
|
#include "gdk-pixbuf-private.h"
|
1999-12-02 20:44:43 +00:00
|
|
|
|
#include "gdk-pixbuf-io.h"
|
2001-05-07 15:58:47 +00:00
|
|
|
|
#include "io-gif-animation.h"
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
2003-06-21 00:46:49 +00:00
|
|
|
|
#undef DUMP_IMAGE_DETAILS
|
|
|
|
|
#undef IO_GIFDEBUG
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
#define MAXCOLORMAPSIZE 256
|
1999-11-03 17:45:24 +00:00
|
|
|
|
#define MAX_LZW_BITS 12
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
|
|
|
|
#define INTERLACE 0x40
|
|
|
|
|
#define LOCALCOLORMAP 0x80
|
|
|
|
|
#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
|
|
|
|
|
#define LM_to_uint(a,b) (((b)<<8)|(a))
|
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
|
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
typedef unsigned char CMap[3][MAXCOLORMAPSIZE];
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* Possible states we can be in. */
|
|
|
|
|
enum {
|
1999-11-03 21:22:38 +00:00
|
|
|
|
GIF_START,
|
1999-11-02 23:49:22 +00:00
|
|
|
|
GIF_GET_COLORMAP,
|
|
|
|
|
GIF_GET_NEXT_STEP,
|
|
|
|
|
GIF_GET_FRAME_INFO,
|
2002-10-20 22:16:58 +00:00
|
|
|
|
GIF_GET_EXTENSION,
|
1999-11-02 23:49:22 +00:00
|
|
|
|
GIF_GET_COLORMAP2,
|
|
|
|
|
GIF_PREPARE_LZW,
|
|
|
|
|
GIF_LZW_FILL_BUFFER,
|
1999-11-03 21:22:38 +00:00
|
|
|
|
GIF_LZW_CLEAR_CODE,
|
1999-11-02 23:49:22 +00:00
|
|
|
|
GIF_GET_LZW,
|
2001-05-07 15:58:47 +00:00
|
|
|
|
GIF_DONE
|
1999-11-02 01:17:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
typedef struct _Gif89 Gif89;
|
|
|
|
|
struct _Gif89
|
|
|
|
|
{
|
|
|
|
|
int transparent;
|
1999-11-10 21:06:40 +00:00
|
|
|
|
int delay_time;
|
|
|
|
|
int input_flag;
|
|
|
|
|
int disposal;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct _GifContext GifContext;
|
|
|
|
|
struct _GifContext
|
1999-10-20 21:20:49 +00:00
|
|
|
|
{
|
1999-11-02 01:17:41 +00:00
|
|
|
|
int state; /* really only relevant for progressive loading */
|
1999-10-30 19:28:53 +00:00
|
|
|
|
unsigned int width;
|
|
|
|
|
unsigned int height;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
gboolean has_global_cmap;
|
|
|
|
|
|
|
|
|
|
CMap global_color_map;
|
|
|
|
|
gint global_colormap_size;
|
|
|
|
|
unsigned int global_bit_pixel;
|
|
|
|
|
unsigned int global_color_resolution;
|
|
|
|
|
unsigned int background_index;
|
|
|
|
|
|
|
|
|
|
gboolean frame_cmap_active;
|
|
|
|
|
CMap frame_color_map;
|
|
|
|
|
gint frame_colormap_size;
|
|
|
|
|
unsigned int frame_bit_pixel;
|
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
unsigned int aspect_ratio;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
GdkPixbufGifAnim *animation;
|
1999-12-20 22:51:05 +00:00
|
|
|
|
GdkPixbufFrame *frame;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
Gif89 gif89;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
/* stuff per frame. */
|
1999-11-01 13:26:03 +00:00
|
|
|
|
int frame_len;
|
|
|
|
|
int frame_height;
|
|
|
|
|
int frame_interlace;
|
2000-02-03 23:36:14 +00:00
|
|
|
|
int x_offset;
|
|
|
|
|
int y_offset;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
|
|
|
|
/* Static read only */
|
|
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
|
|
/* progressive read, only. */
|
2002-10-03 22:39:51 +00:00
|
|
|
|
GdkPixbufModulePreparedFunc prepare_func;
|
|
|
|
|
GdkPixbufModuleUpdatedFunc update_func;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
gpointer user_data;
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
guchar *buf;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
guint ptr;
|
|
|
|
|
guint size;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
guint amount_needed;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* extension context */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
guchar extension_label;
|
|
|
|
|
guchar extension_flag;
|
2002-10-20 22:16:58 +00:00
|
|
|
|
gboolean in_loop_extension;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* get block context */
|
|
|
|
|
guchar block_count;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
guchar block_buf[280];
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gint block_ptr;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
int old_state; /* used by lzw_fill buffer */
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* get_code context */
|
|
|
|
|
int code_curbit;
|
|
|
|
|
int code_lastbit;
|
|
|
|
|
int code_done;
|
|
|
|
|
int code_last_byte;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
int lzw_code_pending;
|
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
/* lzw context */
|
|
|
|
|
gint lzw_fresh;
|
|
|
|
|
gint lzw_code_size;
|
|
|
|
|
guchar lzw_set_code_size;
|
|
|
|
|
gint lzw_max_code;
|
|
|
|
|
gint lzw_max_code_size;
|
|
|
|
|
gint lzw_firstcode;
|
|
|
|
|
gint lzw_oldcode;
|
|
|
|
|
gint lzw_clear_code;
|
|
|
|
|
gint lzw_end_code;
|
|
|
|
|
gint *lzw_sp;
|
|
|
|
|
|
|
|
|
|
gint lzw_table[2][(1 << MAX_LZW_BITS)];
|
|
|
|
|
gint lzw_stack[(1 << (MAX_LZW_BITS)) * 2 + 1];
|
1999-11-03 16:40:43 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* painting context */
|
|
|
|
|
gint draw_xpos;
|
|
|
|
|
gint draw_ypos;
|
|
|
|
|
gint draw_pass;
|
2000-10-18 18:42:54 +00:00
|
|
|
|
|
|
|
|
|
/* error pointer */
|
|
|
|
|
GError **error;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
};
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-01 13:26:03 +00:00
|
|
|
|
static int GetDataBlock (GifContext *, unsigned char *);
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
|
|
|
|
|
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
1999-11-03 16:40:43 +00:00
|
|
|
|
static int count = 0;
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
/* Returns TRUE if read is OK,
|
1999-11-02 23:49:22 +00:00
|
|
|
|
* FALSE if more memory is needed. */
|
2001-06-01 23:05:46 +00:00
|
|
|
|
static gboolean
|
1999-11-03 23:22:27 +00:00
|
|
|
|
gif_read (GifContext *context, guchar *buffer, size_t len)
|
1999-11-01 13:26:03 +00:00
|
|
|
|
{
|
2001-06-01 23:05:46 +00:00
|
|
|
|
gboolean retval;
|
1999-11-03 00:20:27 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
|
|
|
|
gint i;
|
|
|
|
|
#endif
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (context->file) {
|
|
|
|
|
#ifdef IO_GIFDEBUG
|
1999-11-03 22:19:42 +00:00
|
|
|
|
count += len;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
g_print ("Fsize :%d\tcount :%d\t", len, count);
|
|
|
|
|
#endif
|
2001-05-07 15:58:47 +00:00
|
|
|
|
retval = (fread(buffer, len, 1, context->file) != 0);
|
|
|
|
|
|
|
|
|
|
if (!retval && ferror (context->file))
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
G_FILE_ERROR,
|
|
|
|
|
g_file_error_from_errno (errno),
|
|
|
|
|
_("Failure reading GIF: %s"), strerror (errno));
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
|
|
|
|
if (len < 100) {
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
g_print ("%d ", buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
g_print ("\n");
|
|
|
|
|
#endif
|
2000-10-18 18:42:54 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return retval;
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef IO_GIFDEBUG
|
2000-01-02 03:59:22 +00:00
|
|
|
|
/* g_print ("\tlooking for %d bytes. size == %d, ptr == %d\n", len, context->size, context->ptr); */
|
1999-11-02 23:49:22 +00:00
|
|
|
|
#endif
|
|
|
|
|
if ((context->size - context->ptr) >= len) {
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
1999-11-02 23:49:22 +00:00
|
|
|
|
count += len;
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
memcpy (buffer, context->buf + context->ptr, len);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->ptr += len;
|
|
|
|
|
context->amount_needed = 0;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
|
|
|
|
g_print ("Psize :%d\tcount :%d\t", len, count);
|
|
|
|
|
if (len < 100) {
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
g_print ("%d ", buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
g_print ("\n");
|
|
|
|
|
#endif
|
|
|
|
|
return TRUE;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
}
|
|
|
|
|
context->amount_needed = len - (context->size - context->ptr);
|
|
|
|
|
}
|
2003-03-06 20:19:11 +00:00
|
|
|
|
return FALSE;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* Changes the stage to be GIF_GET_COLORMAP */
|
|
|
|
|
static void
|
|
|
|
|
gif_set_get_colormap (GifContext *context)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
{
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->global_colormap_size = 0;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->state = GIF_GET_COLORMAP;
|
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
static void
|
|
|
|
|
gif_set_get_colormap2 (GifContext *context)
|
|
|
|
|
{
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_colormap_size = 0;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->state = GIF_GET_COLORMAP2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
gif_get_colormap (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
unsigned char rgb[3];
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
while (context->global_colormap_size < context->global_bit_pixel) {
|
|
|
|
|
if (!gif_read (context, rgb, sizeof (rgb))) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->global_color_map[0][context->global_colormap_size] = rgb[0];
|
|
|
|
|
context->global_color_map[1][context->global_colormap_size] = rgb[1];
|
|
|
|
|
context->global_color_map[2][context->global_colormap_size] = rgb[2];
|
|
|
|
|
|
|
|
|
|
if (context->global_colormap_size == context->background_index) {
|
|
|
|
|
context->animation->bg_red = rgb[0];
|
|
|
|
|
context->animation->bg_green = rgb[1];
|
|
|
|
|
context->animation->bg_blue = rgb[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->global_colormap_size ++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
gif_get_colormap2 (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
unsigned char rgb[3];
|
|
|
|
|
|
|
|
|
|
while (context->frame_colormap_size < context->frame_bit_pixel) {
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, rgb, sizeof (rgb))) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_color_map[0][context->frame_colormap_size] = rgb[0];
|
|
|
|
|
context->frame_color_map[1][context->frame_colormap_size] = rgb[1];
|
|
|
|
|
context->frame_color_map[2][context->frame_colormap_size] = rgb[2];
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_colormap_size ++;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return 0;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
}
|
1999-06-29 06:07:14 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/*
|
|
|
|
|
* in order for this function to work, we need to perform some black magic.
|
|
|
|
|
* We want to return -1 to let the calling function know, as before, that it needs
|
|
|
|
|
* more bytes. If we return 0, we were able to successfully read all block->count bytes.
|
|
|
|
|
* Problem is, we don't want to reread block_count every time, so we check to see if
|
|
|
|
|
* context->block_count is 0 before we read in the function.
|
|
|
|
|
*
|
|
|
|
|
* As a result, context->block_count MUST be 0 the first time the get_data_block is called
|
1999-11-02 23:49:22 +00:00
|
|
|
|
* within a context, and cannot be 0 the second time it's called.
|
1999-11-02 01:17:41 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
static int
|
1999-11-02 01:17:41 +00:00
|
|
|
|
get_data_block (GifContext *context,
|
|
|
|
|
unsigned char *buf,
|
|
|
|
|
gint *empty_block)
|
1999-06-29 06:07:14 +00:00
|
|
|
|
{
|
1999-11-02 01:17:41 +00:00
|
|
|
|
|
|
|
|
|
if (context->block_count == 0) {
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, &context->block_count, 1)) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
1999-10-30 22:04:27 +00:00
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
if (context->block_count == 0)
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (empty_block) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
*empty_block = TRUE;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, buf, context->block_count)) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gif_set_get_extension (GifContext *context)
|
|
|
|
|
{
|
2002-10-20 22:16:58 +00:00
|
|
|
|
context->state = GIF_GET_EXTENSION;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->extension_flag = TRUE;
|
1999-11-03 05:12:02 +00:00
|
|
|
|
context->extension_label = 0;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->block_count = 0;
|
|
|
|
|
context->block_ptr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
gif_get_extension (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
gint retval;
|
|
|
|
|
gint empty_block = FALSE;
|
|
|
|
|
|
|
|
|
|
if (context->extension_flag) {
|
1999-11-03 05:12:02 +00:00
|
|
|
|
if (context->extension_label == 0) {
|
|
|
|
|
/* I guess bad things can happen if we have an extension of 0 )-: */
|
|
|
|
|
/* I should look into this sometime */
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, & context->extension_label , 1)) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (context->extension_label) {
|
2002-10-20 22:16:58 +00:00
|
|
|
|
case 0xf9: /* Graphic Control Extension */
|
|
|
|
|
retval = get_data_block (context, (unsigned char *) context->block_buf, NULL);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
if (retval != 0)
|
|
|
|
|
return retval;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
if (context->frame == NULL) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* I only want to set the transparency if I haven't
|
2001-05-07 15:58:47 +00:00
|
|
|
|
* created the frame yet.
|
|
|
|
|
*/
|
1999-12-20 22:51:05 +00:00
|
|
|
|
context->gif89.disposal = (context->block_buf[0] >> 2) & 0x7;
|
|
|
|
|
context->gif89.input_flag = (context->block_buf[0] >> 1) & 0x1;
|
|
|
|
|
context->gif89.delay_time = LM_to_uint (context->block_buf[1], context->block_buf[2]);
|
|
|
|
|
|
1999-11-03 22:19:42 +00:00
|
|
|
|
if ((context->block_buf[0] & 0x1) != 0) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->gif89.transparent = context->block_buf[3];
|
1999-11-03 22:19:42 +00:00
|
|
|
|
} else {
|
2000-02-20 03:08:00 +00:00
|
|
|
|
context->gif89.transparent = -1;
|
1999-11-03 22:19:42 +00:00
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
}
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* Now we've successfully loaded this one, we continue on our way */
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->block_count = 0;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->extension_flag = FALSE;
|
2002-10-20 22:16:58 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0xff: /* application extension */
|
|
|
|
|
if (!context->in_loop_extension) {
|
|
|
|
|
retval = get_data_block (context, (unsigned char *) context->block_buf, NULL);
|
|
|
|
|
if (retval != 0)
|
|
|
|
|
return retval;
|
|
|
|
|
if (!strncmp (context->block_buf, "NETSCAPE2.0", 11) ||
|
|
|
|
|
!strncmp (context->block_buf, "ANIMEXTS1.0", 11)) {
|
|
|
|
|
context->in_loop_extension = TRUE;
|
|
|
|
|
}
|
2003-06-22 18:08:33 +00:00
|
|
|
|
context->block_count = 0;
|
2002-10-20 22:16:58 +00:00
|
|
|
|
}
|
|
|
|
|
if (context->in_loop_extension) {
|
|
|
|
|
do {
|
|
|
|
|
retval = get_data_block (context, (unsigned char *) context->block_buf, &empty_block);
|
|
|
|
|
if (retval != 0)
|
|
|
|
|
return retval;
|
|
|
|
|
if (context->block_buf[0] == 0x01) {
|
|
|
|
|
context->animation->loop = context->block_buf[1] + (context->block_buf[2] << 8);
|
|
|
|
|
if (context->animation->loop != 0)
|
|
|
|
|
context->animation->loop++;
|
|
|
|
|
}
|
|
|
|
|
context->block_count = 0;
|
|
|
|
|
}
|
|
|
|
|
while (!empty_block);
|
|
|
|
|
context->in_loop_extension = FALSE;
|
|
|
|
|
context->extension_flag = FALSE;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
default:
|
|
|
|
|
/* Unhandled extension */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-03 05:12:02 +00:00
|
|
|
|
/* read all blocks, until I get an empty block, in case there was an extension I didn't know about. */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
do {
|
|
|
|
|
retval = get_data_block (context, (unsigned char *) context->block_buf, &empty_block);
|
|
|
|
|
if (retval != 0)
|
|
|
|
|
return retval;
|
1999-11-03 05:12:02 +00:00
|
|
|
|
context->block_count = 0;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
} while (!empty_block);
|
|
|
|
|
|
|
|
|
|
return 0;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-31 01:13:25 +00:00
|
|
|
|
static int ZeroDataBlock = FALSE;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
|
|
|
|
static int
|
1999-11-02 01:17:41 +00:00
|
|
|
|
GetDataBlock (GifContext *context,
|
1999-10-30 19:28:53 +00:00
|
|
|
|
unsigned char *buf)
|
|
|
|
|
{
|
2000-01-02 03:59:22 +00:00
|
|
|
|
/* unsigned char count; */
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, &context->block_count, 1)) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
/*g_message (_("GIF: error in getting DataBlock size\n"));*/
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
ZeroDataBlock = context->block_count == 0;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if ((context->block_count != 0) && (!gif_read (context, buf, context->block_count))) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
/*g_message (_("GIF: error in reading DataBlock\n"));*/
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return context->block_count;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gif_set_lzw_fill_buffer (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
context->block_count = 0;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
context->old_state = context->state;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->state = GIF_LZW_FILL_BUFFER;
|
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
|
|
|
|
static int
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_lzw_fill_buffer (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
gint retval;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (context->code_done) {
|
|
|
|
|
if (context->code_curbit >= context->code_lastbit) {
|
2000-10-18 18:42:54 +00:00
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF file was missing some data (perhaps it was truncated somehow?)"));
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return -2;
|
|
|
|
|
}
|
2000-10-18 18:42:54 +00:00
|
|
|
|
/* Is this supposed to be an error or what? */
|
|
|
|
|
/* g_message ("trying to read more data after we've done stuff\n"); */
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_FAILED,
|
|
|
|
|
_("Internal error in the GIF loader (%s)"),
|
|
|
|
|
G_STRLOC);
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->block_buf[0] = context->block_buf[context->code_last_byte - 2];
|
|
|
|
|
context->block_buf[1] = context->block_buf[context->code_last_byte - 1];
|
|
|
|
|
|
|
|
|
|
retval = get_data_block (context, &context->block_buf[2], NULL);
|
|
|
|
|
|
|
|
|
|
if (retval == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (context->block_count == 0)
|
|
|
|
|
context->code_done = TRUE;
|
|
|
|
|
|
|
|
|
|
context->code_last_byte = 2 + context->block_count;
|
|
|
|
|
context->code_curbit = (context->code_curbit - context->code_lastbit) + 16;
|
|
|
|
|
context->code_lastbit = (2 + context->block_count) * 8;
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
context->state = context->old_state;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
1999-11-03 21:22:38 +00:00
|
|
|
|
get_code (GifContext *context,
|
|
|
|
|
int code_size)
|
1999-11-02 23:49:22 +00:00
|
|
|
|
{
|
|
|
|
|
int i, j, ret;
|
|
|
|
|
|
|
|
|
|
if ((context->code_curbit + code_size) >= context->code_lastbit){
|
|
|
|
|
gif_set_lzw_fill_buffer (context);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
for (i = context->code_curbit, j = 0; j < code_size; ++i, ++j)
|
|
|
|
|
ret |= ((context->block_buf[i / 8] & (1 << (i % 8))) != 0) << j;
|
|
|
|
|
|
|
|
|
|
context->code_curbit += code_size;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_gif_lzw_clear_code (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
context->state = GIF_LZW_CLEAR_CODE;
|
|
|
|
|
context->lzw_code_pending = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
gif_lzw_clear_code (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
gint code;
|
|
|
|
|
|
|
|
|
|
code = get_code (context, context->lzw_code_size);
|
|
|
|
|
if (code == -3)
|
|
|
|
|
return -0;
|
|
|
|
|
|
|
|
|
|
context->lzw_firstcode = context->lzw_oldcode = code;
|
|
|
|
|
context->lzw_code_pending = code;
|
|
|
|
|
context->state = GIF_GET_LZW;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-11-02 23:49:22 +00:00
|
|
|
|
|
2002-11-06 20:26:27 +00:00
|
|
|
|
#define CHECK_LZW_SP() G_STMT_START { \
|
|
|
|
|
if ((guchar *)context->lzw_sp >= \
|
|
|
|
|
(guchar *)context->lzw_stack + sizeof (context->lzw_stack)) { \
|
|
|
|
|
g_set_error (context->error, \
|
|
|
|
|
GDK_PIXBUF_ERROR, \
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, \
|
|
|
|
|
_("Stack overflow")); \
|
|
|
|
|
return -2; \
|
|
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
2002-10-22 22:41:58 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
static int
|
1999-11-03 17:45:24 +00:00
|
|
|
|
lzw_read_byte (GifContext *context)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
{
|
|
|
|
|
int code, incode;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gint retval;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
gint my_retval;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
register int i;
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
if (context->lzw_code_pending != -1) {
|
|
|
|
|
retval = context->lzw_code_pending;
|
|
|
|
|
context->lzw_code_pending = -1;
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
if (context->lzw_fresh) {
|
|
|
|
|
context->lzw_fresh = FALSE;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
do {
|
1999-11-03 21:22:38 +00:00
|
|
|
|
retval = get_code (context, context->lzw_code_size);
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (retval < 0) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
context->lzw_firstcode = context->lzw_oldcode = retval;
|
|
|
|
|
} while (context->lzw_firstcode == context->lzw_clear_code);
|
|
|
|
|
return context->lzw_firstcode;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
if (context->lzw_sp > context->lzw_stack) {
|
|
|
|
|
my_retval = *--(context->lzw_sp);
|
|
|
|
|
return my_retval;
|
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
while ((code = get_code (context, context->lzw_code_size)) >= 0) {
|
1999-11-03 17:45:24 +00:00
|
|
|
|
if (code == context->lzw_clear_code) {
|
|
|
|
|
for (i = 0; i < context->lzw_clear_code; ++i) {
|
|
|
|
|
context->lzw_table[0][i] = 0;
|
|
|
|
|
context->lzw_table[1][i] = i;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-11-03 17:45:24 +00:00
|
|
|
|
for (; i < (1 << MAX_LZW_BITS); ++i)
|
|
|
|
|
context->lzw_table[0][i] = context->lzw_table[1][i] = 0;
|
|
|
|
|
context->lzw_code_size = context->lzw_set_code_size + 1;
|
|
|
|
|
context->lzw_max_code_size = 2 * context->lzw_clear_code;
|
|
|
|
|
context->lzw_max_code = context->lzw_clear_code + 2;
|
|
|
|
|
context->lzw_sp = context->lzw_stack;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
|
|
|
|
set_gif_lzw_clear_code (context);
|
|
|
|
|
return -3;
|
1999-11-03 17:45:24 +00:00
|
|
|
|
} else if (code == context->lzw_end_code) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
int count;
|
|
|
|
|
unsigned char buf[260];
|
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
/* FIXME - we should handle this case */
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_FAILED,
|
2004-06-12 02:08:45 +00:00
|
|
|
|
_("GIF image loader cannot understand this image."));
|
2001-06-01 23:05:46 +00:00
|
|
|
|
return -2;
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
if (ZeroDataBlock) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
return -2;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-01 13:26:03 +00:00
|
|
|
|
while ((count = GetDataBlock (context, buf)) > 0)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
;
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
if (count != 0) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
/*g_print (_("GIF: missing EOD in data stream (common occurence)"));*/
|
1999-11-03 21:22:38 +00:00
|
|
|
|
return -2;
|
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
incode = code;
|
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
if (code >= context->lzw_max_code) {
|
2002-10-22 22:41:58 +00:00
|
|
|
|
CHECK_LZW_SP ();
|
1999-11-03 17:45:24 +00:00
|
|
|
|
*(context->lzw_sp)++ = context->lzw_firstcode;
|
|
|
|
|
code = context->lzw_oldcode;
|
1999-06-29 06:07:14 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
while (code >= context->lzw_clear_code) {
|
2002-10-22 22:41:58 +00:00
|
|
|
|
if (code >= (1 << MAX_LZW_BITS)) {
|
2001-09-14 22:04:55 +00:00
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("Bad code encountered"));
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
2002-10-22 22:41:58 +00:00
|
|
|
|
CHECK_LZW_SP ();
|
1999-11-03 17:45:24 +00:00
|
|
|
|
*(context->lzw_sp)++ = context->lzw_table[1][code];
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
if (code == context->lzw_table[0][code]) {
|
2000-10-18 18:42:54 +00:00
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("Circular table entry in GIF file"));
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return -2;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-11-03 17:45:24 +00:00
|
|
|
|
code = context->lzw_table[0][code];
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
2002-10-22 22:41:58 +00:00
|
|
|
|
CHECK_LZW_SP ();
|
1999-11-03 17:45:24 +00:00
|
|
|
|
*(context->lzw_sp)++ = context->lzw_firstcode = context->lzw_table[1][code];
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
if ((code = context->lzw_max_code) < (1 << MAX_LZW_BITS)) {
|
|
|
|
|
context->lzw_table[0][code] = context->lzw_oldcode;
|
|
|
|
|
context->lzw_table[1][code] = context->lzw_firstcode;
|
|
|
|
|
++context->lzw_max_code;
|
|
|
|
|
if ((context->lzw_max_code >= context->lzw_max_code_size) &&
|
|
|
|
|
(context->lzw_max_code_size < (1 << MAX_LZW_BITS))) {
|
|
|
|
|
context->lzw_max_code_size *= 2;
|
|
|
|
|
++context->lzw_code_size;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
context->lzw_oldcode = incode;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
if (context->lzw_sp > context->lzw_stack) {
|
|
|
|
|
my_retval = *--(context->lzw_sp);
|
|
|
|
|
return my_retval;
|
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
return code;
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-30 22:04:27 +00:00
|
|
|
|
static void
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_get_lzw (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
context->state = GIF_GET_LZW;
|
|
|
|
|
context->draw_xpos = 0;
|
|
|
|
|
context->draw_ypos = 0;
|
|
|
|
|
context->draw_pass = 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-03 00:20:27 +00:00
|
|
|
|
static void
|
|
|
|
|
gif_fill_in_pixels (GifContext *context, guchar *dest, gint offset, guchar v)
|
|
|
|
|
{
|
|
|
|
|
guchar *pixel = NULL;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
guchar (*cmap)[MAXCOLORMAPSIZE];
|
1999-11-03 00:20:27 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->frame_cmap_active)
|
|
|
|
|
cmap = context->frame_color_map;
|
|
|
|
|
else
|
|
|
|
|
cmap = context->global_color_map;
|
|
|
|
|
|
2000-02-20 03:08:00 +00:00
|
|
|
|
if (context->gif89.transparent != -1) {
|
2001-05-07 15:58:47 +00:00
|
|
|
|
pixel = dest + (context->draw_ypos + offset) * gdk_pixbuf_get_rowstride (context->frame->pixbuf) + context->draw_xpos * 4;
|
|
|
|
|
*pixel = cmap [0][(guchar) v];
|
|
|
|
|
*(pixel+1) = cmap [1][(guchar) v];
|
|
|
|
|
*(pixel+2) = cmap [2][(guchar) v];
|
|
|
|
|
*(pixel+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 255);
|
1999-11-03 00:20:27 +00:00
|
|
|
|
} else {
|
2001-05-07 15:58:47 +00:00
|
|
|
|
pixel = dest + (context->draw_ypos + offset) * gdk_pixbuf_get_rowstride (context->frame->pixbuf) + context->draw_xpos * 3;
|
|
|
|
|
*pixel = cmap [0][(guchar) v];
|
|
|
|
|
*(pixel+1) = cmap [1][(guchar) v];
|
|
|
|
|
*(pixel+2) = cmap [2][(guchar) v];
|
1999-11-03 00:20:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* only called if progressive and interlaced */
|
|
|
|
|
static void
|
|
|
|
|
gif_fill_in_lines (GifContext *context, guchar *dest, guchar v)
|
|
|
|
|
{
|
|
|
|
|
switch (context->draw_pass) {
|
|
|
|
|
case 0:
|
|
|
|
|
if (context->draw_ypos > 4) {
|
|
|
|
|
gif_fill_in_pixels (context, dest, -4, v);
|
|
|
|
|
gif_fill_in_pixels (context, dest, -3, v);
|
|
|
|
|
}
|
|
|
|
|
if (context->draw_ypos < (context->frame_height - 4)) {
|
|
|
|
|
gif_fill_in_pixels (context, dest, 3, v);
|
|
|
|
|
gif_fill_in_pixels (context, dest, 4, v);
|
|
|
|
|
}
|
1999-12-03 21:57:07 +00:00
|
|
|
|
/* we don't need a break here. We draw the outer pixels first, then the
|
|
|
|
|
* inner ones, then the innermost ones. case 0 needs to draw all 3 bands.
|
|
|
|
|
* case 1, just the last two, and case 2 just draws the last one*/
|
1999-11-03 00:20:27 +00:00
|
|
|
|
case 1:
|
|
|
|
|
if (context->draw_ypos > 2)
|
|
|
|
|
gif_fill_in_pixels (context, dest, -2, v);
|
|
|
|
|
if (context->draw_ypos < (context->frame_height - 2))
|
|
|
|
|
gif_fill_in_pixels (context, dest, 2, v);
|
1999-12-03 21:57:07 +00:00
|
|
|
|
/* no break as above. */
|
1999-11-03 00:20:27 +00:00
|
|
|
|
case 2:
|
|
|
|
|
if (context->draw_ypos > 1)
|
|
|
|
|
gif_fill_in_pixels (context, dest, -1, v);
|
|
|
|
|
if (context->draw_ypos < (context->frame_height - 1))
|
|
|
|
|
gif_fill_in_pixels (context, dest, 1, v);
|
|
|
|
|
case 3:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-22 18:08:33 +00:00
|
|
|
|
/* Clips a rectancle to the base dimensions. Returns TRUE if the clipped rectangle is non-empty. */
|
|
|
|
|
static gboolean
|
|
|
|
|
clip_frame (GifContext *context,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
|
|
|
|
{
|
|
|
|
|
gint orig_x, orig_y;
|
|
|
|
|
|
|
|
|
|
orig_x = *x;
|
|
|
|
|
orig_y = *y;
|
|
|
|
|
*x = MAX (0, *x);
|
|
|
|
|
*y = MAX (0, *y);
|
|
|
|
|
*width = MIN (context->width, orig_x + *width) - *x;
|
|
|
|
|
*height = MIN (context->height, orig_y + *height) - *y;
|
|
|
|
|
|
|
|
|
|
if (*width > 0 && *height > 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
/* The frame is completely off-bounds */
|
|
|
|
|
|
|
|
|
|
*x = 0;
|
|
|
|
|
*y = 0;
|
|
|
|
|
*width = 0;
|
|
|
|
|
*height = 0;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call update_func on the given rectangle, unless it is completely off-bounds */
|
|
|
|
|
static void
|
|
|
|
|
maybe_update (GifContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
|
|
|
|
if (clip_frame (context, &x, &y, &width, &height))
|
|
|
|
|
(*context->update_func) (context->frame->pixbuf,
|
|
|
|
|
x, y, width, height,
|
|
|
|
|
context->user_data);
|
|
|
|
|
}
|
2002-02-01 23:43:07 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
static int
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gif_get_lzw (GifContext *context)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
{
|
|
|
|
|
guchar *dest, *temp;
|
1999-11-04 20:34:24 +00:00
|
|
|
|
gint lower_bound, upper_bound; /* bounds for emitting the area_updated signal */
|
|
|
|
|
gboolean bound_flag;
|
|
|
|
|
gint first_pass; /* bounds for emitting the area_updated signal */
|
1999-10-30 19:28:53 +00:00
|
|
|
|
gint v;
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->frame == NULL) {
|
|
|
|
|
context->frame = g_new (GdkPixbufFrame, 1);
|
|
|
|
|
|
|
|
|
|
context->frame->composited = NULL;
|
|
|
|
|
context->frame->revert = NULL;
|
|
|
|
|
|
2003-06-21 00:46:49 +00:00
|
|
|
|
if (context->frame_len == 0 || context->frame_height == 0) {
|
|
|
|
|
/* An empty frame, we just output a single transparent
|
|
|
|
|
* pixel at (0, 0).
|
|
|
|
|
*/
|
|
|
|
|
context->x_offset = 0;
|
|
|
|
|
context->y_offset = 0;
|
|
|
|
|
context->frame_len = 1;
|
|
|
|
|
context->frame_height = 1;
|
|
|
|
|
context->frame->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
|
|
|
|
|
if (context->frame->pixbuf) {
|
|
|
|
|
guchar *pixels;
|
|
|
|
|
|
|
|
|
|
pixels = gdk_pixbuf_get_pixels (context->frame->pixbuf);
|
|
|
|
|
pixels[0] = 0;
|
|
|
|
|
pixels[1] = 0;
|
|
|
|
|
pixels[2] = 0;
|
|
|
|
|
pixels[3] = 0;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
context->frame->pixbuf =
|
|
|
|
|
gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
|
|
|
|
TRUE,
|
|
|
|
|
8,
|
|
|
|
|
context->frame_len,
|
|
|
|
|
context->frame_height);
|
2001-06-01 23:05:46 +00:00
|
|
|
|
if (!context->frame->pixbuf) {
|
|
|
|
|
g_free (context->frame);
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load GIF file"));
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame->x_offset = context->x_offset;
|
|
|
|
|
context->frame->y_offset = context->y_offset;
|
|
|
|
|
context->frame->need_recomposite = TRUE;
|
|
|
|
|
|
|
|
|
|
/* GIF delay is in hundredths, we want thousandths */
|
|
|
|
|
context->frame->delay_time = context->gif89.delay_time * 10;
|
2001-06-08 20:15:49 +00:00
|
|
|
|
|
|
|
|
|
/* Some GIFs apparently have delay time of 0,
|
|
|
|
|
* that crashes everything so set it to "fast".
|
|
|
|
|
* Also, timeouts less than 20 or so just lock up
|
|
|
|
|
* the app or make the animation choppy, so fix them.
|
|
|
|
|
*/
|
|
|
|
|
if (context->frame->delay_time < 20)
|
|
|
|
|
context->frame->delay_time = 20; /* 20 = "fast" */
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame->elapsed = context->animation->total_time;
|
2001-06-08 20:15:49 +00:00
|
|
|
|
context->animation->total_time += context->frame->delay_time;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
switch (context->gif89.disposal) {
|
|
|
|
|
case 0:
|
|
|
|
|
case 1:
|
|
|
|
|
context->frame->action = GDK_PIXBUF_FRAME_RETAIN;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
context->frame->action = GDK_PIXBUF_FRAME_DISPOSE;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
context->frame->action = GDK_PIXBUF_FRAME_REVERT;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
context->frame->action = GDK_PIXBUF_FRAME_RETAIN;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->frame->bg_transparent = (context->gif89.transparent == context->background_index);
|
|
|
|
|
|
2003-06-22 18:08:33 +00:00
|
|
|
|
context->animation->n_frames ++;
|
|
|
|
|
context->animation->frames = g_list_append (context->animation->frames, context->frame);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
/* Only call prepare_func for the first frame */
|
|
|
|
|
if (context->animation->frames->next == NULL) {
|
|
|
|
|
if (context->prepare_func)
|
|
|
|
|
(* context->prepare_func) (context->frame->pixbuf,
|
|
|
|
|
GDK_PIXBUF_ANIMATION (context->animation),
|
|
|
|
|
context->user_data);
|
|
|
|
|
} else {
|
|
|
|
|
/* Otherwise init frame with last frame */
|
|
|
|
|
GList *link;
|
|
|
|
|
GdkPixbufFrame *prev_frame;
|
2003-06-22 18:08:33 +00:00
|
|
|
|
gint x, y, w, h;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
link = g_list_find (context->animation->frames, context->frame);
|
|
|
|
|
|
|
|
|
|
prev_frame = link->prev->data;
|
|
|
|
|
|
|
|
|
|
gdk_pixbuf_gif_anim_frame_composite (context->animation, prev_frame);
|
|
|
|
|
|
2005-03-03 13:29:01 +00:00
|
|
|
|
/* Composite failed */
|
|
|
|
|
if (prev_frame->composited == NULL) {
|
|
|
|
|
GdkPixbufFrame *frame = NULL;
|
|
|
|
|
link = g_list_first (context->animation->frames);
|
|
|
|
|
while (link != NULL) {
|
|
|
|
|
frame = (GdkPixbufFrame *)link->data;
|
|
|
|
|
if (frame != NULL) {
|
|
|
|
|
if (frame->pixbuf != NULL)
|
|
|
|
|
g_object_unref (frame->pixbuf);
|
|
|
|
|
if (frame->composited != NULL)
|
|
|
|
|
g_object_unref (frame->composited);
|
|
|
|
|
if (frame->revert != NULL)
|
|
|
|
|
g_object_unref (frame->revert);
|
|
|
|
|
g_free (frame);
|
|
|
|
|
}
|
|
|
|
|
link = link->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_free (context->animation->frames);
|
|
|
|
|
context->animation->frames = NULL;
|
|
|
|
|
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to composite a frame in GIF file"));
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-22 18:08:33 +00:00
|
|
|
|
x = context->frame->x_offset;
|
|
|
|
|
y = context->frame->y_offset;
|
|
|
|
|
w = gdk_pixbuf_get_width (context->frame->pixbuf);
|
|
|
|
|
h = gdk_pixbuf_get_height (context->frame->pixbuf);
|
|
|
|
|
if (clip_frame (context, &x, &y, &w, &h))
|
|
|
|
|
gdk_pixbuf_copy_area (prev_frame->composited,
|
|
|
|
|
x, y, w, h,
|
|
|
|
|
context->frame->pixbuf,
|
|
|
|
|
0, 0);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dest = gdk_pixbuf_get_pixels (context->frame->pixbuf);
|
1999-11-04 20:34:24 +00:00
|
|
|
|
|
|
|
|
|
bound_flag = FALSE;
|
|
|
|
|
lower_bound = upper_bound = context->draw_ypos;
|
|
|
|
|
first_pass = context->draw_pass;
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
while (TRUE) {
|
2001-05-07 15:58:47 +00:00
|
|
|
|
guchar (*cmap)[MAXCOLORMAPSIZE];
|
|
|
|
|
|
|
|
|
|
if (context->frame_cmap_active)
|
|
|
|
|
cmap = context->frame_color_map;
|
|
|
|
|
else
|
|
|
|
|
cmap = context->global_color_map;
|
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
v = lzw_read_byte (context);
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (v < 0) {
|
1999-11-04 20:34:24 +00:00
|
|
|
|
goto finished_data;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
}
|
1999-11-04 20:34:24 +00:00
|
|
|
|
bound_flag = TRUE;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
g_assert (gdk_pixbuf_get_has_alpha (context->frame->pixbuf));
|
|
|
|
|
|
|
|
|
|
temp = dest + context->draw_ypos * gdk_pixbuf_get_rowstride (context->frame->pixbuf) + context->draw_xpos * 4;
|
|
|
|
|
*temp = cmap [0][(guchar) v];
|
|
|
|
|
*(temp+1) = cmap [1][(guchar) v];
|
|
|
|
|
*(temp+2) = cmap [2][(guchar) v];
|
|
|
|
|
*(temp+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 255);
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-04 18:18:07 +00:00
|
|
|
|
if (context->prepare_func && context->frame_interlace)
|
1999-11-03 00:20:27 +00:00
|
|
|
|
gif_fill_in_lines (context, dest, v);
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_xpos++;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (context->draw_xpos == context->frame_len) {
|
|
|
|
|
context->draw_xpos = 0;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
if (context->frame_interlace) {
|
1999-11-02 23:49:22 +00:00
|
|
|
|
switch (context->draw_pass) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
case 0:
|
|
|
|
|
case 1:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos += 8;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos += 4;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos += 2;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (context->draw_ypos >= context->frame_height) {
|
|
|
|
|
context->draw_pass++;
|
|
|
|
|
switch (context->draw_pass) {
|
1999-10-30 19:28:53 +00:00
|
|
|
|
case 1:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos = 4;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos = 2;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos = 1;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-11-02 01:17:41 +00:00
|
|
|
|
goto done;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-30 19:28:53 +00:00
|
|
|
|
} else {
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->draw_ypos++;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-11-04 20:34:24 +00:00
|
|
|
|
if (context->draw_pass != first_pass) {
|
|
|
|
|
if (context->draw_ypos > lower_bound) {
|
|
|
|
|
lower_bound = 0;
|
|
|
|
|
upper_bound = context->frame_height;
|
|
|
|
|
} else {
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
upper_bound = context->draw_ypos;
|
1999-06-29 06:07:14 +00:00
|
|
|
|
}
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (context->draw_ypos >= context->frame_height)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
done:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
context->state = GIF_GET_NEXT_STEP;
|
|
|
|
|
|
|
|
|
|
v = 0;
|
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
finished_data:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
if (bound_flag)
|
|
|
|
|
context->frame->need_recomposite = TRUE;
|
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
if (bound_flag && context->update_func) {
|
|
|
|
|
if (lower_bound <= upper_bound && first_pass == context->draw_pass) {
|
2003-06-22 18:08:33 +00:00
|
|
|
|
maybe_update (context,
|
|
|
|
|
context->frame->x_offset,
|
|
|
|
|
context->frame->y_offset + lower_bound,
|
|
|
|
|
gdk_pixbuf_get_width (context->frame->pixbuf),
|
|
|
|
|
upper_bound - lower_bound);
|
1999-11-04 20:34:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (lower_bound <= upper_bound) {
|
2003-06-22 18:08:33 +00:00
|
|
|
|
maybe_update (context,
|
|
|
|
|
context->frame->x_offset,
|
|
|
|
|
context->frame->y_offset,
|
|
|
|
|
gdk_pixbuf_get_width (context->frame->pixbuf),
|
|
|
|
|
gdk_pixbuf_get_height (context->frame->pixbuf));
|
1999-11-04 20:34:24 +00:00
|
|
|
|
} else {
|
2003-06-22 18:08:33 +00:00
|
|
|
|
maybe_update (context,
|
|
|
|
|
context->frame->x_offset,
|
|
|
|
|
context->frame->y_offset,
|
|
|
|
|
gdk_pixbuf_get_width (context->frame->pixbuf),
|
|
|
|
|
upper_bound);
|
|
|
|
|
maybe_update (context,
|
|
|
|
|
context->frame->x_offset,
|
|
|
|
|
context->frame->y_offset + lower_bound,
|
|
|
|
|
gdk_pixbuf_get_width (context->frame->pixbuf),
|
|
|
|
|
gdk_pixbuf_get_height (context->frame->pixbuf) - lower_bound);
|
1999-11-04 20:34:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->state == GIF_GET_NEXT_STEP) {
|
|
|
|
|
/* Will be freed with context->animation, we are just
|
|
|
|
|
* marking that we're done with it (no current frame)
|
|
|
|
|
*/
|
1999-12-20 22:51:05 +00:00
|
|
|
|
context->frame = NULL;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_cmap_active = FALSE;
|
1999-12-20 22:51:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 20:34:24 +00:00
|
|
|
|
return v;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gif_set_prepare_lzw (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
context->state = GIF_PREPARE_LZW;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
context->lzw_code_pending = -1;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
static int
|
|
|
|
|
gif_prepare_lzw (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
gint i;
|
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, &(context->lzw_set_code_size), 1)) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/*g_message (_("GIF: EOF / read error on image data\n"));*/
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2001-06-01 23:05:46 +00:00
|
|
|
|
|
|
|
|
|
if (context->lzw_set_code_size > MAX_LZW_BITS) {
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF image is corrupt (incorrect LZW compression)"));
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
context->lzw_code_size = context->lzw_set_code_size + 1;
|
|
|
|
|
context->lzw_clear_code = 1 << context->lzw_set_code_size;
|
|
|
|
|
context->lzw_end_code = context->lzw_clear_code + 1;
|
|
|
|
|
context->lzw_max_code_size = 2 * context->lzw_clear_code;
|
|
|
|
|
context->lzw_max_code = context->lzw_clear_code + 2;
|
|
|
|
|
context->lzw_fresh = TRUE;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->code_curbit = 0;
|
|
|
|
|
context->code_lastbit = 0;
|
1999-11-03 16:40:43 +00:00
|
|
|
|
context->code_last_byte = 0;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->code_done = FALSE;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
g_assert (context->lzw_clear_code <=
|
|
|
|
|
G_N_ELEMENTS (context->lzw_table[0]));
|
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
for (i = 0; i < context->lzw_clear_code; ++i) {
|
|
|
|
|
context->lzw_table[0][i] = 0;
|
|
|
|
|
context->lzw_table[1][i] = i;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
}
|
1999-11-03 17:45:24 +00:00
|
|
|
|
for (; i < (1 << MAX_LZW_BITS); ++i)
|
|
|
|
|
context->lzw_table[0][i] = context->lzw_table[1][0] = 0;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
1999-11-03 17:45:24 +00:00
|
|
|
|
context->lzw_sp = context->lzw_stack;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_get_lzw (context);
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* needs 13 bytes to proceed. */
|
1999-11-01 13:26:03 +00:00
|
|
|
|
static gint
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gif_init (GifContext *context)
|
1999-10-30 19:28:53 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned char buf[16];
|
|
|
|
|
char version[4];
|
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, buf, 6)) {
|
2000-10-18 18:42:54 +00:00
|
|
|
|
/* Unable to read magic number,
|
|
|
|
|
* gif_read() should have set error
|
|
|
|
|
*/
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
if (strncmp ((char *) buf, "GIF", 3) != 0) {
|
|
|
|
|
/* Not a GIF file */
|
2000-10-18 18:42:54 +00:00
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("File does not appear to be a GIF file"));
|
2001-09-14 22:04:55 +00:00
|
|
|
|
return -2;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
strncpy (version, (char *) buf + 3, 3);
|
|
|
|
|
version[3] = '\0';
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
if ((strcmp (version, "87a") != 0) && (strcmp (version, "89a") != 0)) {
|
|
|
|
|
/* bad version number, not '87a' or '89a' */
|
2000-10-18 18:42:54 +00:00
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("Version %s of the GIF file format is not supported"),
|
|
|
|
|
version);
|
2001-09-14 22:04:55 +00:00
|
|
|
|
return -2;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-06-29 06:07:14 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
/* read the screen descriptor */
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, buf, 7)) {
|
2000-10-18 18:42:54 +00:00
|
|
|
|
/* Failed to read screen descriptor, error set */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-09-22 22:30:51 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
context->width = LM_to_uint (buf[0], buf[1]);
|
|
|
|
|
context->height = LM_to_uint (buf[2], buf[3]);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
/* The 4th byte is
|
|
|
|
|
* high bit: whether to use the background index
|
|
|
|
|
* next 3: color resolution
|
|
|
|
|
* next: whether colormap is sorted by priority of allocation
|
|
|
|
|
* last 3: size of colormap
|
|
|
|
|
*/
|
|
|
|
|
context->global_bit_pixel = 2 << (buf[4] & 0x07);
|
|
|
|
|
context->global_color_resolution = (((buf[4] & 0x70) >> 3) + 1);
|
|
|
|
|
context->has_global_cmap = (buf[4] & 0x80) != 0;
|
|
|
|
|
context->background_index = buf[5];
|
1999-10-30 19:28:53 +00:00
|
|
|
|
context->aspect_ratio = buf[6];
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
/* Use background of transparent black as default, though if
|
|
|
|
|
* one isn't set explicitly no one should ever use it.
|
|
|
|
|
*/
|
|
|
|
|
context->animation->bg_red = 0;
|
|
|
|
|
context->animation->bg_green = 0;
|
|
|
|
|
context->animation->bg_blue = 0;
|
2003-06-22 18:08:33 +00:00
|
|
|
|
|
|
|
|
|
context->animation->width = context->width;
|
|
|
|
|
context->animation->height = context->height;
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->has_global_cmap) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gif_set_get_colormap (context);
|
|
|
|
|
} else {
|
|
|
|
|
context->state = GIF_GET_NEXT_STEP;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DUMP_IMAGE_DETAILS
|
|
|
|
|
g_print (">Image width: %d height: %d global_cmap: %d background: %d\n",
|
|
|
|
|
context->width, context->height, context->has_global_cmap, context->background_index);
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gif_set_get_frame_info (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
context->state = GIF_GET_FRAME_INFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
gif_get_frame_info (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
unsigned char buf[9];
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, buf, 9)) {
|
1999-11-02 23:49:22 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* Okay, we got all the info we need. Lets record it */
|
|
|
|
|
context->frame_len = LM_to_uint (buf[4], buf[5]);
|
|
|
|
|
context->frame_height = LM_to_uint (buf[6], buf[7]);
|
2000-02-03 23:36:14 +00:00
|
|
|
|
context->x_offset = LM_to_uint (buf[0], buf[1]);
|
|
|
|
|
context->y_offset = LM_to_uint (buf[2], buf[3]);
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->animation->frames == NULL &&
|
|
|
|
|
context->gif89.disposal == 3) {
|
|
|
|
|
/* First frame can't have "revert to previous" as its
|
2003-06-23 20:20:15 +00:00
|
|
|
|
* dispose mode. Silently use "retain" instead.
|
2001-05-07 15:58:47 +00:00
|
|
|
|
*/
|
2003-06-23 20:20:15 +00:00
|
|
|
|
context->gif89.disposal = 0;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-21 00:46:49 +00:00
|
|
|
|
context->frame_interlace = BitSet (buf[8], INTERLACE);
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
#ifdef DUMP_IMAGE_DETAILS
|
2003-06-21 00:46:49 +00:00
|
|
|
|
g_print (">width: %d height: %d xoffset: %d yoffset: %d disposal: %d delay: %d transparent: %d interlace: %d\n",
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_len, context->frame_height, context->x_offset, context->y_offset,
|
2003-06-21 00:46:49 +00:00
|
|
|
|
context->gif89.disposal, context->gif89.delay_time, context->gif89.transparent, context->frame_interlace);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
if (BitSet (buf[8], LOCALCOLORMAP)) {
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DUMP_IMAGE_DETAILS
|
|
|
|
|
g_print (">has local colormap\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* Does this frame have it's own colormap. */
|
|
|
|
|
/* really only relevant when looking at the first frame
|
|
|
|
|
* of an animated gif. */
|
|
|
|
|
/* if it does, we need to re-read in the colormap,
|
|
|
|
|
* the gray_scale, and the bit_pixel */
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->frame_cmap_active = TRUE;
|
|
|
|
|
context->frame_bit_pixel = 1 << ((buf[8] & 0x07) + 1);
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_get_colormap2 (context);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
if (!context->has_global_cmap) {
|
|
|
|
|
context->state = GIF_DONE;
|
|
|
|
|
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF image has no global colormap, and a frame inside it has no local colormap."));
|
|
|
|
|
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_prepare_lzw (context);
|
|
|
|
|
return 0;
|
|
|
|
|
|
1999-11-03 21:22:38 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
static gint
|
|
|
|
|
gif_get_next_step (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
unsigned char c;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
while (TRUE) {
|
1999-11-03 23:22:27 +00:00
|
|
|
|
if (!gif_read (context, &c, 1)) {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return -1;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
|
|
|
|
if (c == ';') {
|
|
|
|
|
/* GIF terminator */
|
1999-11-01 13:26:03 +00:00
|
|
|
|
/* hmm. Not 100% sure what to do about this. Should
|
|
|
|
|
* i try to return a blank image instead? */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->state = GIF_DONE;
|
2000-10-09 17:22:20 +00:00
|
|
|
|
return 0;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-10-28 14:46:46 +00:00
|
|
|
|
|
1999-10-30 19:28:53 +00:00
|
|
|
|
if (c == '!') {
|
2003-09-03 19:57:05 +00:00
|
|
|
|
/* Check the extension */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gif_set_get_extension (context);
|
1999-11-03 05:12:02 +00:00
|
|
|
|
return 0;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
|
|
|
|
|
/* look for frame */
|
1999-10-30 19:28:53 +00:00
|
|
|
|
if (c != ',') {
|
1999-11-02 01:17:41 +00:00
|
|
|
|
/* Not a valid start character */
|
1999-10-30 19:28:53 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
1999-11-03 21:22:38 +00:00
|
|
|
|
/* load the frame */
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_get_frame_info (context);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return 0;
|
1999-10-30 19:28:53 +00:00
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
#define LOG(x) /* g_print ("%d: %s\n", __LINE__, x); */
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
static gint
|
|
|
|
|
gif_main_loop (GifContext *context)
|
|
|
|
|
{
|
|
|
|
|
gint retval = 0;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
switch (context->state) {
|
|
|
|
|
case GIF_START:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("start\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_init (context);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIF_GET_COLORMAP:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("get_colormap\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_get_colormap (context);
|
|
|
|
|
if (retval == 0)
|
|
|
|
|
context->state = GIF_GET_NEXT_STEP;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIF_GET_NEXT_STEP:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("next_step\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_get_next_step (context);
|
|
|
|
|
break;
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
case GIF_GET_FRAME_INFO:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("frame_info\n");
|
1999-11-02 23:49:22 +00:00
|
|
|
|
retval = gif_get_frame_info (context);
|
|
|
|
|
break;
|
|
|
|
|
|
2002-10-20 22:16:58 +00:00
|
|
|
|
case GIF_GET_EXTENSION:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("get_extension\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_get_extension (context);
|
|
|
|
|
if (retval == 0)
|
|
|
|
|
context->state = GIF_GET_NEXT_STEP;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIF_GET_COLORMAP2:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("get_colormap2\n");
|
|
|
|
|
retval = gif_get_colormap2 (context);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
if (retval == 0)
|
1999-11-02 23:49:22 +00:00
|
|
|
|
gif_set_prepare_lzw (context);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIF_PREPARE_LZW:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("prepare_lzw\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_prepare_lzw (context);
|
|
|
|
|
break;
|
|
|
|
|
|
1999-11-02 23:49:22 +00:00
|
|
|
|
case GIF_LZW_FILL_BUFFER:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("fill_buffer\n");
|
1999-11-02 23:49:22 +00:00
|
|
|
|
retval = gif_lzw_fill_buffer (context);
|
|
|
|
|
break;
|
1999-11-03 21:22:38 +00:00
|
|
|
|
|
|
|
|
|
case GIF_LZW_CLEAR_CODE:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("clear_code\n");
|
1999-11-03 21:22:38 +00:00
|
|
|
|
retval = gif_lzw_clear_code (context);
|
|
|
|
|
break;
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
case GIF_GET_LZW:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("get_lzw\n");
|
1999-11-02 23:49:22 +00:00
|
|
|
|
retval = gif_get_lzw (context);
|
1999-11-02 01:17:41 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIF_DONE:
|
2001-05-07 15:58:47 +00:00
|
|
|
|
LOG("done\n");
|
1999-11-02 01:17:41 +00:00
|
|
|
|
default:
|
|
|
|
|
retval = 0;
|
|
|
|
|
goto done;
|
|
|
|
|
};
|
1999-11-02 23:49:22 +00:00
|
|
|
|
} while ((retval == 0) || (retval == -3));
|
1999-11-02 01:17:41 +00:00
|
|
|
|
done:
|
|
|
|
|
return retval;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-10 21:06:40 +00:00
|
|
|
|
static GifContext *
|
|
|
|
|
new_context (void)
|
|
|
|
|
{
|
|
|
|
|
GifContext *context;
|
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
context = g_try_malloc (sizeof (GifContext));
|
|
|
|
|
if (context == NULL)
|
|
|
|
|
return NULL;
|
2000-02-03 23:36:14 +00:00
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
memset (context, 0, sizeof (GifContext));
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->animation = g_object_new (GDK_TYPE_PIXBUF_GIF_ANIM, NULL);
|
|
|
|
|
context->frame = NULL;
|
1999-11-10 21:06:40 +00:00
|
|
|
|
context->file = NULL;
|
|
|
|
|
context->state = GIF_START;
|
|
|
|
|
context->prepare_func = NULL;
|
|
|
|
|
context->update_func = NULL;
|
|
|
|
|
context->user_data = NULL;
|
|
|
|
|
context->buf = NULL;
|
|
|
|
|
context->amount_needed = 0;
|
|
|
|
|
context->gif89.transparent = -1;
|
|
|
|
|
context->gif89.delay_time = -1;
|
|
|
|
|
context->gif89.input_flag = -1;
|
|
|
|
|
context->gif89.disposal = -1;
|
2002-10-20 22:16:58 +00:00
|
|
|
|
context->animation->loop = 1;
|
|
|
|
|
context->in_loop_extension = FALSE;
|
2000-02-03 23:36:14 +00:00
|
|
|
|
|
1999-11-10 21:06:40 +00:00
|
|
|
|
return context;
|
|
|
|
|
}
|
1999-11-01 13:26:03 +00:00
|
|
|
|
/* Shared library entry point */
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
static GdkPixbuf *
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gdk_pixbuf__gif_image_load (FILE *file, GError **error)
|
1999-11-01 13:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
GifContext *context;
|
2000-03-09 00:11:30 +00:00
|
|
|
|
GdkPixbuf *pixbuf;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (file != NULL, NULL);
|
1999-10-28 14:46:46 +00:00
|
|
|
|
|
1999-11-10 21:06:40 +00:00
|
|
|
|
context = new_context ();
|
2001-06-01 23:05:46 +00:00
|
|
|
|
|
|
|
|
|
if (context == NULL) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load GIF file"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-01 13:26:03 +00:00
|
|
|
|
context->file = file;
|
2000-10-18 18:42:54 +00:00
|
|
|
|
context->error = error;
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (gif_main_loop (context) == -1 || context->animation->frames == NULL) {
|
|
|
|
|
if (context->error && *(context->error) == NULL)
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF file was missing some data (perhaps it was truncated somehow?)"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_animation_get_static_image (GDK_PIXBUF_ANIMATION (context->animation));
|
1999-11-01 13:26:03 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (pixbuf)
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
g_object_ref (pixbuf);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
g_object_unref (context->animation);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
g_free (context->buf);
|
2000-03-09 00:11:30 +00:00
|
|
|
|
g_free (context);
|
|
|
|
|
|
|
|
|
|
return pixbuf;
|
1999-10-28 14:46:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
static gpointer
|
2002-10-03 22:39:51 +00:00
|
|
|
|
gdk_pixbuf__gif_image_begin_load (GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepare_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc update_func,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
1999-11-01 13:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
GifContext *context;
|
|
|
|
|
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#ifdef IO_GIFDEBUG
|
1999-11-02 23:49:22 +00:00
|
|
|
|
count = 0;
|
1999-11-03 22:19:42 +00:00
|
|
|
|
#endif
|
1999-11-10 21:06:40 +00:00
|
|
|
|
context = new_context ();
|
2001-06-01 23:05:46 +00:00
|
|
|
|
|
|
|
|
|
if (context == NULL) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load GIF file"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-18 18:42:54 +00:00
|
|
|
|
context->error = error;
|
1999-11-04 18:18:07 +00:00
|
|
|
|
context->prepare_func = prepare_func;
|
1999-11-04 20:34:24 +00:00
|
|
|
|
context->update_func = update_func;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
context->user_data = user_data;
|
1999-11-10 21:06:40 +00:00
|
|
|
|
|
1999-11-01 13:26:03 +00:00
|
|
|
|
return (gpointer) context;
|
|
|
|
|
}
|
|
|
|
|
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_pixbuf__gif_image_stop_load (gpointer data, GError **error)
|
1999-11-01 13:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
GifContext *context = (GifContext *) data;
|
2001-05-07 15:58:47 +00:00
|
|
|
|
gboolean retval = TRUE;
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (context->state != GIF_DONE) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF image was truncated or incomplete."));
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
}
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
g_object_unref (context->animation);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
|
|
|
|
g_free (context->buf);
|
1999-11-01 13:26:03 +00:00
|
|
|
|
g_free (context);
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
return retval;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_pixbuf__gif_image_load_increment (gpointer data,
|
|
|
|
|
const guchar *buf, guint size,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
GError **error)
|
1999-11-01 13:26:03 +00:00
|
|
|
|
{
|
1999-11-02 01:17:41 +00:00
|
|
|
|
gint retval;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
GifContext *context = (GifContext *) data;
|
|
|
|
|
|
2000-10-18 18:42:54 +00:00
|
|
|
|
context->error = error;
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
if (context->amount_needed == 0) {
|
|
|
|
|
/* we aren't looking for some bytes. */
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* we can use buf now, but we don't want to keep it around at all.
|
|
|
|
|
* it will be gone by the end of the call. */
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
context->buf = (guchar*) buf; /* very dubious const cast */
|
1999-11-02 01:17:41 +00:00
|
|
|
|
context->ptr = 0;
|
|
|
|
|
context->size = size;
|
1999-11-02 23:49:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
/* we need some bytes */
|
|
|
|
|
if (size < context->amount_needed) {
|
|
|
|
|
context->amount_needed -= size;
|
|
|
|
|
/* copy it over and return */
|
|
|
|
|
memcpy (context->buf + context->size, buf, size);
|
|
|
|
|
context->size += size;
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else if (size == context->amount_needed) {
|
|
|
|
|
memcpy (context->buf + context->size, buf, size);
|
|
|
|
|
context->size += size;
|
|
|
|
|
} else {
|
|
|
|
|
context->buf = g_realloc (context->buf, context->size + size);
|
|
|
|
|
memcpy (context->buf + context->size, buf, size);
|
|
|
|
|
context->size += size;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-02 01:17:41 +00:00
|
|
|
|
retval = gif_main_loop (context);
|
1999-11-02 23:49:22 +00:00
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
if (retval == -2) {
|
2002-03-25 23:22:01 +00:00
|
|
|
|
if (context->buf == buf)
|
|
|
|
|
context->buf = NULL;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
return FALSE;
|
2001-06-01 23:05:46 +00:00
|
|
|
|
}
|
1999-11-02 01:17:41 +00:00
|
|
|
|
if (retval == -1) {
|
1999-11-02 23:49:22 +00:00
|
|
|
|
/* we didn't have enough memory */
|
|
|
|
|
/* prepare for the next image_load_increment */
|
|
|
|
|
if (context->buf == buf) {
|
|
|
|
|
g_assert (context->size == size);
|
|
|
|
|
context->buf = (guchar *)g_new (guchar, context->amount_needed + (context->size - context->ptr));
|
|
|
|
|
memcpy (context->buf, buf + context->ptr, context->size - context->ptr);
|
|
|
|
|
} else {
|
|
|
|
|
/* copy the left overs to the begining of the buffer */
|
|
|
|
|
/* and realloc the memory */
|
1999-11-03 21:52:16 +00:00
|
|
|
|
memmove (context->buf, context->buf + context->ptr, context->size - context->ptr);
|
1999-11-02 23:49:22 +00:00
|
|
|
|
context->buf = g_realloc (context->buf, context->amount_needed + (context->size - context->ptr));
|
|
|
|
|
}
|
|
|
|
|
context->size = context->size - context->ptr;
|
|
|
|
|
context->ptr = 0;
|
|
|
|
|
} else {
|
|
|
|
|
/* we are prolly all done */
|
|
|
|
|
if (context->buf == buf)
|
|
|
|
|
context->buf = NULL;
|
1999-11-02 01:17:41 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
1999-11-01 13:26:03 +00:00
|
|
|
|
}
|
1999-12-20 22:51:05 +00:00
|
|
|
|
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
static GdkPixbufAnimation *
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gdk_pixbuf__gif_image_load_animation (FILE *file,
|
|
|
|
|
GError **error)
|
1999-12-20 22:51:05 +00:00
|
|
|
|
{
|
|
|
|
|
GifContext *context;
|
2000-03-09 00:11:30 +00:00
|
|
|
|
GdkPixbufAnimation *animation;
|
1999-12-20 22:51:05 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (file != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
context = new_context ();
|
2000-10-18 18:42:54 +00:00
|
|
|
|
|
2001-06-01 23:05:46 +00:00
|
|
|
|
if (context == NULL) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load GIF file"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-18 18:42:54 +00:00
|
|
|
|
context->error = error;
|
1999-12-20 22:51:05 +00:00
|
|
|
|
context->file = file;
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
if (gif_main_loop (context) == -1 || context->animation->frames == NULL) {
|
|
|
|
|
if (context->error && *(context->error) == NULL)
|
|
|
|
|
g_set_error (context->error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("GIF file was missing some data (perhaps it was truncated somehow?)"));
|
2000-03-09 00:11:30 +00:00
|
|
|
|
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
g_object_unref (context->animation);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
context->animation = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (context->animation)
|
|
|
|
|
animation = GDK_PIXBUF_ANIMATION (context->animation);
|
|
|
|
|
else
|
|
|
|
|
animation = NULL;
|
|
|
|
|
|
|
|
|
|
if (context->error && *(context->error))
|
|
|
|
|
g_print ("%s\n", (*(context->error))->message);
|
|
|
|
|
|
|
|
|
|
g_free (context->buf);
|
2000-03-09 00:11:30 +00:00
|
|
|
|
g_free (context);
|
|
|
|
|
return animation;
|
1999-12-20 22:51:05 +00:00
|
|
|
|
}
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
|
|
|
|
|
void
|
2002-10-03 22:39:51 +00:00
|
|
|
|
MODULE_ENTRY (gif, fill_vtable) (GdkPixbufModule *module)
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
{
|
2002-10-03 22:39:51 +00:00
|
|
|
|
module->load = gdk_pixbuf__gif_image_load;
|
|
|
|
|
module->begin_load = gdk_pixbuf__gif_image_begin_load;
|
|
|
|
|
module->stop_load = gdk_pixbuf__gif_image_stop_load;
|
|
|
|
|
module->load_increment = gdk_pixbuf__gif_image_load_increment;
|
|
|
|
|
module->load_animation = gdk_pixbuf__gif_image_load_animation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MODULE_ENTRY (gif, fill_info) (GdkPixbufFormat *info)
|
|
|
|
|
{
|
|
|
|
|
static GdkPixbufModulePattern signature[] = {
|
|
|
|
|
{ "GIF8", NULL, 100 },
|
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
static gchar * mime_types[] = {
|
|
|
|
|
"image/gif",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
static gchar * extensions[] = {
|
|
|
|
|
"gif",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
info->name = "gif";
|
|
|
|
|
info->signature = signature;
|
|
|
|
|
info->description = N_("The GIF image format");
|
|
|
|
|
info->mime_types = mime_types;
|
|
|
|
|
info->extensions = extensions;
|
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
|
|
|
|
info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
|
2004-07-08 03:56:36 +00:00
|
|
|
|
info->license = "LGPL";
|
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
|
|
|
|
}
|