2002-10-03 22:39:51 +00:00
|
|
|
|
/* -*- mode: C; c-file-style: "linux" -*- */
|
1999-11-05 22:42:17 +00:00
|
|
|
|
/* GdkPixbuf library - SUNRAS image loader
|
1999-11-05 20:37:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 1999 The Free Software Foundation
|
|
|
|
|
*
|
|
|
|
|
* Authors: Arjan van de Ven <arjan@fenrus.demon.nl>
|
|
|
|
|
* Federico Mena-Quintero <federico@gimp.org>
|
|
|
|
|
*
|
1999-11-08 19:37:45 +00:00
|
|
|
|
* Based on io-gif.c, io-tiff.c and io-png.c
|
|
|
|
|
*
|
1999-11-05 20:37:08 +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-11-05 20:37:08 +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-11-05 20:37:08 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-11-05 20:37:08 +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-11-17 21:02:33 +00:00
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Known bugs:
|
1999-11-10 18:47:39 +00:00
|
|
|
|
* Compressed rasterfiles don't work yet
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
*/
|
1999-11-05 20:37:08 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <stdio.h>
|
2000-08-01 21:43:56 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-11-17 21:02:33 +00:00
|
|
|
|
#include <unistd.h>
|
2000-08-01 21:43:56 +00:00
|
|
|
|
#endif
|
1999-12-07 18:17:01 +00:00
|
|
|
|
#include <string.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"
|
|
|
|
|
|
1999-11-05 20:37:08 +00:00
|
|
|
|
|
|
|
|
|
|
1999-11-05 22:42:17 +00:00
|
|
|
|
/*
|
|
|
|
|
Header structure for sunras files.
|
1999-11-05 20:37:08 +00:00
|
|
|
|
All values are in big-endian order on disk
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
Note: Every scanline is padded to be a multiple of 16 bits
|
1999-11-05 20:37:08 +00:00
|
|
|
|
*/
|
1999-11-05 22:42:17 +00:00
|
|
|
|
|
|
|
|
|
struct rasterfile {
|
|
|
|
|
guint magic;
|
|
|
|
|
guint width;
|
|
|
|
|
guint height;
|
|
|
|
|
guint depth;
|
|
|
|
|
guint length;
|
|
|
|
|
guint type;
|
|
|
|
|
guint maptype;
|
|
|
|
|
guint maplength;
|
1999-11-05 20:37:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
1999-11-05 22:42:17 +00:00
|
|
|
|
This does a byte-order swap. Does glib have something like
|
|
|
|
|
be32_to_cpu() ??
|
1999-11-05 20:37:08 +00:00
|
|
|
|
*/
|
1999-11-05 22:42:17 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
/* Progressive loading */
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
struct ras_progressive_state {
|
2004-01-07 00:26:58 +00:00
|
|
|
|
GdkPixbufModuleSizeFunc size_func;
|
2002-10-03 22:39:51 +00:00
|
|
|
|
GdkPixbufModulePreparedFunc prepared_func;
|
|
|
|
|
GdkPixbufModuleUpdatedFunc updated_func;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
gpointer user_data;
|
1999-11-05 22:42:17 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
gint HeaderSize; /* The size of the header-part (incl colormap) */
|
|
|
|
|
guchar *HeaderBuf; /* The buffer for the header (incl colormap) */
|
|
|
|
|
gint HeaderDone; /* The nr of bytes actually in HeaderBuf */
|
1999-11-05 22:42:17 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
gint LineWidth; /* The width of a line in bytes */
|
|
|
|
|
guchar *LineBuf; /* Buffer for 1 line */
|
|
|
|
|
gint LineDone; /* # of bytes in LineBuf */
|
|
|
|
|
gint Lines; /* # of finished lines */
|
1999-11-05 20:37:08 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
gint RasType; /* 32 = BGRA
|
|
|
|
|
24 = BGR
|
|
|
|
|
8 = 8 bit colormapped
|
|
|
|
|
1 = 1 bit bitonal
|
|
|
|
|
*/
|
2002-07-01 22:30:51 +00:00
|
|
|
|
gint DecoderState;
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
struct rasterfile Header; /* Decoded (BE->CPU) header */
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
GdkPixbuf *pixbuf; /* Our "target" */
|
|
|
|
|
};
|
|
|
|
|
|
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__ras_image_begin_load(GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepared_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc updated_func,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error);
|
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__ras_image_stop_load(gpointer data, GError **error);
|
|
|
|
|
static gboolean gdk_pixbuf__ras_image_load_increment(gpointer data,
|
|
|
|
|
const guchar * buf, guint size,
|
|
|
|
|
GError **error);
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
static gboolean RAS2State(struct rasterfile *RAS,
|
|
|
|
|
struct ras_progressive_state *State,
|
|
|
|
|
GError **error)
|
1999-11-17 21:02:33 +00:00
|
|
|
|
{
|
1999-12-08 21:37:17 +00:00
|
|
|
|
State->Header.width = GUINT32_FROM_BE(RAS->width);
|
|
|
|
|
State->Header.height = GUINT32_FROM_BE(RAS->height);
|
|
|
|
|
State->Header.depth = GUINT32_FROM_BE(RAS->depth);
|
|
|
|
|
State->Header.type = GUINT32_FROM_BE(RAS->type);
|
|
|
|
|
State->Header.maptype = GUINT32_FROM_BE(RAS->maptype);
|
|
|
|
|
State->Header.maplength = GUINT32_FROM_BE(RAS->maplength);
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if ((gint)State->Header.width <= 0 ||
|
|
|
|
|
(gint)State->Header.height <= 0 ||
|
|
|
|
|
State->Header.maplength > 768) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("RAS image has bogus header data"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
State->RasType = State->Header.depth; /* This may be less trivial someday */
|
|
|
|
|
State->HeaderSize = 32 + State->Header.maplength;
|
|
|
|
|
|
|
|
|
|
if (State->RasType == 32)
|
|
|
|
|
State->LineWidth = State->Header.width * 4;
|
2002-03-13 18:11:15 +00:00
|
|
|
|
else if (State->RasType == 24)
|
1999-11-17 21:02:33 +00:00
|
|
|
|
State->LineWidth = State->Header.width * 3;
|
2002-03-13 18:11:15 +00:00
|
|
|
|
else if (State->RasType == 8)
|
1999-11-17 21:02:33 +00:00
|
|
|
|
State->LineWidth = State->Header.width * 1;
|
2002-03-13 18:11:15 +00:00
|
|
|
|
else if (State->RasType == 1) {
|
1999-11-17 21:02:33 +00:00
|
|
|
|
State->LineWidth = State->Header.width / 8;
|
|
|
|
|
if ((State->Header.width & 7) != 0)
|
|
|
|
|
State->LineWidth++;
|
1999-11-05 22:42:17 +00:00
|
|
|
|
}
|
2002-03-13 18:11:15 +00:00
|
|
|
|
else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("RAS image has unknown type"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-11-05 20:37:08 +00:00
|
|
|
|
|
2002-07-01 22:30:51 +00:00
|
|
|
|
if (State->Header.type > 2 || State->Header.maptype > 1) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("unsupported RAS image variation"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
/* Now pad the line to be a multiple of 16 bits */
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if ((State->LineWidth & 1) != 0)
|
|
|
|
|
State->LineWidth++;
|
1999-11-05 20:37:08 +00:00
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if (!State->LineBuf) {
|
|
|
|
|
State->LineBuf = g_try_malloc (State->LineWidth);
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if (!State->LineBuf) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load RAS image"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if (!State->pixbuf) {
|
2004-01-07 00:26:58 +00:00
|
|
|
|
if (State->size_func) {
|
|
|
|
|
gint width = State->Header.width;
|
|
|
|
|
gint height = State->Header.height;
|
|
|
|
|
|
|
|
|
|
(*State->size_func) (&width, &height, State->user_data);
|
|
|
|
|
if (width == 0 || height == 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (State->RasType == 32)
|
2002-03-13 18:11:15 +00:00
|
|
|
|
State->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
|
|
|
|
|
(gint) State->Header.width,
|
|
|
|
|
(gint) State->Header.height);
|
1999-11-17 21:02:33 +00:00
|
|
|
|
else
|
2002-03-13 18:11:15 +00:00
|
|
|
|
State->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
|
|
|
|
|
(gint) State->Header.width,
|
|
|
|
|
(gint) State->Header.height);
|
|
|
|
|
|
|
|
|
|
if (!State->pixbuf) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load RAS image"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (State->prepared_func != NULL)
|
|
|
|
|
/* Notify the client that we are ready to go */
|
|
|
|
|
(*State->prepared_func) (State->pixbuf,
|
2001-05-07 15:58:47 +00:00
|
|
|
|
NULL,
|
1999-11-17 21:02:33 +00:00
|
|
|
|
State->user_data);
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if ((State->Header.maplength == 0) && (State->RasType == 1)) {
|
1999-11-17 21:02:33 +00:00
|
|
|
|
State->HeaderBuf[32] = 255;
|
|
|
|
|
State->HeaderBuf[33] = 0;
|
|
|
|
|
State->HeaderBuf[34] = 255;
|
|
|
|
|
State->HeaderBuf[35] = 0;
|
|
|
|
|
State->HeaderBuf[36] = 255;
|
|
|
|
|
State->HeaderBuf[37] = 0;
|
|
|
|
|
}
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
2002-03-13 18:11:15 +00:00
|
|
|
|
return TRUE;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
}
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* func - called when we have pixmap created (but no image data)
|
|
|
|
|
* user_data - passed as arg 1 to func
|
|
|
|
|
* return context (opaque to user)
|
|
|
|
|
*/
|
|
|
|
|
|
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__ras_image_begin_load(GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepared_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc updated_func,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
1999-11-08 19:37:45 +00:00
|
|
|
|
{
|
|
|
|
|
struct ras_progressive_state *context;
|
|
|
|
|
|
|
|
|
|
context = g_new0(struct ras_progressive_state, 1);
|
2004-01-07 00:26:58 +00:00
|
|
|
|
context->size_func = size_func;
|
1999-11-08 19:37:45 +00:00
|
|
|
|
context->prepared_func = prepared_func;
|
|
|
|
|
context->updated_func = updated_func;
|
|
|
|
|
context->user_data = user_data;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
context->HeaderSize = 32;
|
|
|
|
|
context->HeaderBuf = g_malloc(32 + 768); /* 32 for rasheader,
|
|
|
|
|
768 for the colormap */
|
|
|
|
|
context->HeaderDone = 0;
|
|
|
|
|
|
|
|
|
|
context->LineWidth = 0;
|
|
|
|
|
context->LineBuf = NULL;
|
|
|
|
|
context->LineDone = 0;
|
|
|
|
|
context->Lines = 0;
|
|
|
|
|
|
|
|
|
|
context->RasType = 0;
|
2002-07-01 22:30:51 +00:00
|
|
|
|
context->DecoderState = 0;
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
memset(&context->Header, 0, sizeof(struct rasterfile));
|
|
|
|
|
|
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
context->pixbuf = NULL;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
return (gpointer) context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* context - returned from image_begin_load
|
|
|
|
|
*
|
|
|
|
|
* free context, unref gdk_pixbuf
|
|
|
|
|
*/
|
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__ras_image_stop_load(gpointer data, GError **error)
|
1999-11-08 19:37:45 +00:00
|
|
|
|
{
|
|
|
|
|
struct ras_progressive_state *context =
|
|
|
|
|
(struct ras_progressive_state *) 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
|
|
|
|
/* FIXME this thing needs to report errors if
|
|
|
|
|
* we have unused image data
|
|
|
|
|
*/
|
1999-11-17 21:02:33 +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
|
|
|
|
g_return_val_if_fail(context != NULL, TRUE);
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (context->LineBuf != NULL)
|
|
|
|
|
g_free(context->LineBuf);
|
|
|
|
|
if (context->HeaderBuf != NULL)
|
|
|
|
|
g_free(context->HeaderBuf);
|
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
if (context->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_unref(context->pixbuf);
|
1999-11-08 19:37:45 +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
|
|
|
|
|
|
|
|
|
return TRUE;
|
1999-11-08 19:37:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
/*
|
|
|
|
|
OneLine is called when enough data is received to process 1 line
|
|
|
|
|
of pixels
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void OneLine32(struct ras_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
/* The joys of having a BGR byteorder */
|
|
|
|
|
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
|
|
|
|
|
Pixels[X * 4 + 1] = context->LineBuf[X * 4 + 1];
|
|
|
|
|
Pixels[X * 4 + 2] = context->LineBuf[X * 4 + 0];
|
|
|
|
|
Pixels[X * 4 + 3] = context->LineBuf[X * 4 + 3];
|
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OneLine24(struct ras_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
/* The joys of having a BGR byteorder */
|
|
|
|
|
Pixels[X * 3 + 0] = context->LineBuf[X * 3 + 2];
|
|
|
|
|
Pixels[X * 3 + 1] = context->LineBuf[X * 3 + 1];
|
|
|
|
|
Pixels[X * 3 + 2] = context->LineBuf[X * 3 + 0];
|
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OneLine8(struct ras_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
2002-07-01 22:30:51 +00:00
|
|
|
|
int offset = context->Header.maplength / 3;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
X = 0;
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
/* The joys of having a BGR byteorder */
|
|
|
|
|
Pixels[X * 3 + 0] =
|
|
|
|
|
context->HeaderBuf[context->LineBuf[X] + 32];
|
|
|
|
|
Pixels[X * 3 + 1] =
|
2002-07-01 22:30:51 +00:00
|
|
|
|
context->HeaderBuf[context->LineBuf[X] + offset + 32];
|
1999-11-17 21:02:33 +00:00
|
|
|
|
Pixels[X * 3 + 2] =
|
2002-07-01 22:30:51 +00:00
|
|
|
|
context->HeaderBuf[context->LineBuf[X] + 2*offset + 32];
|
1999-11-17 21:02:33 +00:00
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OneLine1(struct ras_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
int Bit;
|
|
|
|
|
|
|
|
|
|
Bit = (context->LineBuf[X/8])>>(7-(X&7));
|
|
|
|
|
Bit = Bit & 1;
|
|
|
|
|
/* The joys of having a BGR byteorder */
|
|
|
|
|
Pixels[X * 3 + 0] =
|
|
|
|
|
context->HeaderBuf[Bit + 32];
|
|
|
|
|
Pixels[X * 3 + 1] =
|
|
|
|
|
context->HeaderBuf[Bit + 2 + 32];
|
|
|
|
|
Pixels[X * 3 + 2] =
|
|
|
|
|
context->HeaderBuf[Bit + 4 + 32];
|
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void OneLine(struct ras_progressive_state *context)
|
|
|
|
|
{
|
2002-03-13 18:11:15 +00:00
|
|
|
|
context->LineDone = 0;
|
|
|
|
|
if (context->Lines >= context->Header.height)
|
|
|
|
|
return;
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (context->RasType == 32)
|
|
|
|
|
OneLine32(context);
|
|
|
|
|
if (context->RasType == 24)
|
|
|
|
|
OneLine24(context);
|
|
|
|
|
if (context->RasType == 8)
|
|
|
|
|
OneLine8(context);
|
|
|
|
|
if (context->RasType == 1)
|
|
|
|
|
OneLine1(context);
|
|
|
|
|
|
|
|
|
|
context->LineDone = 0;
|
|
|
|
|
context->Lines++;
|
|
|
|
|
|
|
|
|
|
if (context->updated_func != NULL) {
|
|
|
|
|
(*context->updated_func) (context->pixbuf,
|
|
|
|
|
0,
|
|
|
|
|
context->Lines,
|
|
|
|
|
context->Header.width,
|
2002-07-01 22:30:51 +00:00
|
|
|
|
1,
|
2000-01-05 23:06:13 +00:00
|
|
|
|
context->user_data);
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
2002-07-01 22:30:51 +00:00
|
|
|
|
static gboolean
|
2002-07-16 17:32:08 +00:00
|
|
|
|
DoCompressed (struct ras_progressive_state *context,
|
2002-07-01 22:30:51 +00:00
|
|
|
|
const guchar * buf, guint size,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
|
switch (context->DecoderState) {
|
|
|
|
|
case 0:
|
|
|
|
|
if (buf[i] == 0x80)
|
|
|
|
|
context->DecoderState = 1;
|
|
|
|
|
else
|
|
|
|
|
context->LineBuf[context->LineDone++] = buf[i];
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (buf[i] == 0) {
|
|
|
|
|
context->LineBuf[context->LineDone++] = 0x80;
|
|
|
|
|
context->DecoderState = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
context->DecoderState = buf[i] + 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
for (; context->DecoderState; context->DecoderState--) {
|
|
|
|
|
context->LineBuf[context->LineDone++] = buf[i];
|
|
|
|
|
if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0))
|
|
|
|
|
OneLine(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0))
|
|
|
|
|
OneLine(context);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* context - from image_begin_load
|
|
|
|
|
* buf - new image data
|
|
|
|
|
* size - length of new image data
|
|
|
|
|
*
|
2002-03-13 18:11:15 +00:00
|
|
|
|
* append image data onto incrementally built output image
|
1999-11-08 19:37:45 +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__ras_image_load_increment(gpointer data,
|
|
|
|
|
const guchar * buf, guint size,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
GError **error)
|
1999-11-08 19:37:45 +00:00
|
|
|
|
{
|
|
|
|
|
struct ras_progressive_state *context =
|
|
|
|
|
(struct ras_progressive_state *) data;
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
gint BytesToCopy;
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
while (size > 0) {
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (context->HeaderDone < context->HeaderSize) { /* We still
|
|
|
|
|
have headerbytes to do */
|
|
|
|
|
BytesToCopy =
|
|
|
|
|
context->HeaderSize - context->HeaderDone;
|
|
|
|
|
if (BytesToCopy > size)
|
|
|
|
|
BytesToCopy = size;
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
memmove(context->HeaderBuf + context->HeaderDone,
|
1999-11-17 21:02:33 +00:00
|
|
|
|
buf, BytesToCopy);
|
|
|
|
|
|
|
|
|
|
size -= BytesToCopy;
|
|
|
|
|
buf += BytesToCopy;
|
|
|
|
|
context->HeaderDone += BytesToCopy;
|
|
|
|
|
|
2002-07-01 22:30:51 +00:00
|
|
|
|
} else if (context->Header.type == 2) {
|
|
|
|
|
if (!DoCompressed (context, buf, size, error)) {
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
size = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
1999-11-17 21:02:33 +00:00
|
|
|
|
BytesToCopy =
|
|
|
|
|
context->LineWidth - context->LineDone;
|
|
|
|
|
if (BytesToCopy > size)
|
|
|
|
|
BytesToCopy = size;
|
|
|
|
|
|
|
|
|
|
if (BytesToCopy > 0) {
|
1999-12-04 18:17:52 +00:00
|
|
|
|
memmove(context->LineBuf +
|
1999-11-17 21:02:33 +00:00
|
|
|
|
context->LineDone, buf,
|
|
|
|
|
BytesToCopy);
|
|
|
|
|
|
|
|
|
|
size -= BytesToCopy;
|
|
|
|
|
buf += BytesToCopy;
|
|
|
|
|
context->LineDone += BytesToCopy;
|
|
|
|
|
}
|
|
|
|
|
if ((context->LineDone >= context->LineWidth) &&
|
|
|
|
|
(context->LineWidth > 0))
|
|
|
|
|
OneLine(context);
|
1999-11-08 19:37:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-17 21:02:33 +00:00
|
|
|
|
if (context->HeaderDone >= 32)
|
2002-03-13 18:11:15 +00:00
|
|
|
|
if (!RAS2State((struct rasterfile *) context->HeaderBuf,
|
|
|
|
|
context, error)) {
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-11-17 21:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
1999-11-08 19:37:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
1999-11-05 20:37:08 +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 (ras, 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->begin_load = gdk_pixbuf__ras_image_begin_load;
|
|
|
|
|
module->stop_load = gdk_pixbuf__ras_image_stop_load;
|
|
|
|
|
module->load_increment = gdk_pixbuf__ras_image_load_increment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MODULE_ENTRY (ras, fill_info) (GdkPixbufFormat *info)
|
|
|
|
|
{
|
|
|
|
|
static GdkPixbufModulePattern signature[] = {
|
|
|
|
|
{ "\x59\xa6\x6a\x95", NULL, 100 },
|
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
static gchar * mime_types[] = {
|
|
|
|
|
"image/x-cmu-raster",
|
|
|
|
|
"image/x-sun-raster",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
static gchar * extensions[] = {
|
|
|
|
|
"ras",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
info->name = "ras";
|
|
|
|
|
info->signature = signature;
|
|
|
|
|
info->description = N_("The Sun raster 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
|
|
|
|
}
|
2002-03-13 18:11:15 +00:00
|
|
|
|
|