2002-10-03 22:39:51 +00:00
|
|
|
|
/* -*- mode: C; c-file-style: "linux" -*- */
|
1999-11-21 21:28:28 +00:00
|
|
|
|
/* GdkPixbuf library - Windows Bitmap image loader
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 1999 The Free Software Foundation
|
1999-07-08 16:04:16 +00:00
|
|
|
|
*
|
1999-11-21 21:28:28 +00:00
|
|
|
|
* Authors: Arjan van de Ven <arjan@fenrus.demon.nl>
|
|
|
|
|
* Federico Mena-Quintero <federico@gimp.org>
|
|
|
|
|
*
|
|
|
|
|
* Based on io-ras.c
|
1999-07-08 16:04:16 +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-07-08 16:04:16 +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-07-08 16:04:16 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-11-21 21:28:28 +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-07-08 16:04:16 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <stdio.h>
|
2000-08-01 21:43:56 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-11-21 21:28:28 +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"
|
|
|
|
|
#include "gdk-pixbuf-io.h"
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2000-04-11 07:03:25 +00:00
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
#if 0
|
|
|
|
|
/* If these structures were unpacked, they would define the two headers of the
|
|
|
|
|
* BMP file. After them comes the palette, and then the image data.
|
|
|
|
|
*
|
|
|
|
|
* We do not use these structures; we just keep them here for reference.
|
|
|
|
|
*/
|
1999-11-21 21:28:28 +00:00
|
|
|
|
struct BitmapFileHeader {
|
2001-11-29 00:13:02 +00:00
|
|
|
|
guint16 magic;
|
|
|
|
|
guint32 file_size;
|
|
|
|
|
guint32 reserved;
|
|
|
|
|
guint32 data_offset;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct BitmapInfoHeader {
|
2001-11-29 00:13:02 +00:00
|
|
|
|
guint32 header_size;
|
|
|
|
|
guint32 width;
|
|
|
|
|
guint32 height;
|
|
|
|
|
guint16 planes;
|
|
|
|
|
guint16 bpp;
|
|
|
|
|
guint32 compression;
|
|
|
|
|
guint32 data_size;
|
|
|
|
|
guint32 x_ppm;
|
|
|
|
|
guint32 y_ppm;
|
|
|
|
|
guint32 n_colors;
|
|
|
|
|
guint32 n_important_colors;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
};
|
2001-11-29 00:13:02 +00:00
|
|
|
|
#endif
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/* Compression values */
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
|
|
|
|
#define BI_RGB 0
|
|
|
|
|
#define BI_RLE8 1
|
|
|
|
|
#define BI_RLE4 2
|
|
|
|
|
#define BI_BITFIELDS 3
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/* State machine */
|
|
|
|
|
typedef enum {
|
|
|
|
|
READ_STATE_HEADERS, /* Reading the bitmap file header and bitmap info header */
|
|
|
|
|
READ_STATE_PALETTE, /* Reading the palette */
|
|
|
|
|
READ_STATE_BITMASKS, /* Reading the bitmasks for BI_BITFIELDS */
|
|
|
|
|
READ_STATE_DATA, /* Reading the actual image data */
|
|
|
|
|
READ_STATE_ERROR, /* An error occurred; further data will be ignored */
|
|
|
|
|
READ_STATE_DONE /* Done reading the image; further data will be ignored */
|
|
|
|
|
} ReadState;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
DumpBIH printf's the values in a BitmapInfoHeader to the screen, for
|
1999-12-04 18:17:52 +00:00
|
|
|
|
debugging purposes.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
#if DUMPBIH
|
1999-11-24 21:12:24 +00:00
|
|
|
|
static void DumpBIH(unsigned char *BIH)
|
2000-03-06 08:53:57 +00:00
|
|
|
|
{
|
1999-11-24 21:12:24 +00:00
|
|
|
|
printf("biSize = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[3] << 24) + (BIH[2] << 16) + (BIH[1] << 8) +
|
|
|
|
|
(BIH[0]));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
printf("biWidth = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[7] << 24) + (BIH[6] << 16) + (BIH[5] << 8) +
|
|
|
|
|
(BIH[4]));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
printf("biHeight = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[11] << 24) + (BIH[10] << 16) + (BIH[9] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[8]));
|
1999-12-04 18:17:52 +00:00
|
|
|
|
printf("biPlanes = %i \n", (int) (BIH[13] << 8) + (BIH[12]));
|
|
|
|
|
printf("biBitCount = %i \n", (int) (BIH[15] << 8) + (BIH[14]));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
printf("biCompress = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[19] << 24) + (BIH[18] << 16) + (BIH[17] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[16]));
|
|
|
|
|
printf("biSizeImage = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[23] << 24) + (BIH[22] << 16) + (BIH[21] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[20]));
|
|
|
|
|
printf("biXPels = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[27] << 24) + (BIH[26] << 16) + (BIH[25] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[24]));
|
|
|
|
|
printf("biYPels = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[31] << 24) + (BIH[30] << 16) + (BIH[29] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[28]));
|
|
|
|
|
printf("biClrUsed = %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[35] << 24) + (BIH[34] << 16) + (BIH[33] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[32]));
|
|
|
|
|
printf("biClrImprtnt= %i \n",
|
1999-12-04 18:17:52 +00:00
|
|
|
|
(int) (BIH[39] << 24) + (BIH[38] << 16) + (BIH[37] << 8) +
|
1999-11-24 21:12:24 +00:00
|
|
|
|
(BIH[36]));
|
|
|
|
|
}
|
1999-12-04 18:17:52 +00:00
|
|
|
|
#endif
|
|
|
|
|
/* struct headerpair contains the decoded width/height/depth info for
|
|
|
|
|
the current bitmap */
|
1999-11-24 21:12:24 +00:00
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
struct headerpair {
|
2001-05-28 18:28:16 +00:00
|
|
|
|
guint32 size;
|
|
|
|
|
gint32 width;
|
|
|
|
|
gint32 height;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
guint depth;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
guint Negative; /* Negative = 1 -> top down BMP,
|
1999-12-04 18:17:52 +00:00
|
|
|
|
Negative = 0 -> bottom up BMP */
|
2004-02-20 21:23:42 +00:00
|
|
|
|
guint n_colors;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
};
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
1999-11-24 21:12:24 +00:00
|
|
|
|
/* Data needed for the "state" during decompression */
|
|
|
|
|
struct bmp_compression_state {
|
2001-11-29 00:13:02 +00:00
|
|
|
|
gint phase;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
gint run;
|
|
|
|
|
gint count;
|
|
|
|
|
gint x, y;
|
|
|
|
|
guchar *p;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
};
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
/* Progressive loading */
|
|
|
|
|
|
|
|
|
|
struct bmp_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-21 21:28:28 +00:00
|
|
|
|
gpointer user_data;
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
ReadState read_state;
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
guint LineWidth;
|
|
|
|
|
guint Lines; /* # of finished lines */
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
guchar *buff;
|
2004-02-20 21:23:42 +00:00
|
|
|
|
guint BufferSize;
|
|
|
|
|
guint BufferDone;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
|
|
|
|
guchar (*Colormap)[3];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
gint Type; /*
|
1999-12-04 18:17:52 +00:00
|
|
|
|
32 = RGB + alpha
|
1999-11-21 21:28:28 +00:00
|
|
|
|
24 = RGB
|
2001-05-28 18:28:16 +00:00
|
|
|
|
16 = RGB
|
1999-12-04 18:17:52 +00:00
|
|
|
|
4 = 4 bpp colormapped
|
|
|
|
|
8 = 8 bpp colormapped
|
2001-11-29 00:13:02 +00:00
|
|
|
|
1 = 1 bit bitonal
|
1999-11-21 21:28:28 +00:00
|
|
|
|
*/
|
2002-07-02 17:54:06 +00:00
|
|
|
|
guint Compressed;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
struct bmp_compression_state compr;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct headerpair Header; /* Decoded (BE->CPU) header */
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/* Bit masks, shift amounts, and significant bits for BI_BITFIELDS coding */
|
|
|
|
|
int r_mask, r_shift, r_bits;
|
|
|
|
|
int g_mask, g_shift, g_bits;
|
|
|
|
|
int b_mask, b_shift, b_bits;
|
1999-11-21 21:28:28 +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__bmp_image_begin_load(GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepared_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc updated_func,
|
2001-05-07 15:58:47 +00:00
|
|
|
|
gpointer user_data,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
GError **error);
|
2000-02-22 00:29:00 +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__bmp_image_stop_load(gpointer data, GError **error);
|
|
|
|
|
static gboolean gdk_pixbuf__bmp_image_load_increment(gpointer data,
|
|
|
|
|
const guchar * buf,
|
|
|
|
|
guint size,
|
|
|
|
|
GError **error);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
1999-07-08 16:04:16 +00:00
|
|
|
|
|
2002-06-10 16:50:10 +00:00
|
|
|
|
/* Picks up a 32-bit little-endian integer starting at the specified location.
|
|
|
|
|
* Does it by hand instead of dereferencing a simple (gint *) cast due to
|
|
|
|
|
* alignment constraints many platforms.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
lsb_32 (guchar *src)
|
|
|
|
|
{
|
|
|
|
|
return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Same as above, but for 16-bit little-endian integers. */
|
|
|
|
|
static short
|
|
|
|
|
lsb_16 (guchar *src)
|
|
|
|
|
{
|
|
|
|
|
return src[0] | (src[1] << 8);
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
static gboolean grow_buffer (struct bmp_progressive_state *State,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2002-09-03 23:43:21 +00:00
|
|
|
|
guchar *tmp = g_try_realloc (State->buff, State->BufferSize);
|
|
|
|
|
if (!tmp) {
|
2002-07-02 17:54:06 +00:00
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load bitmap image"));
|
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2002-09-03 23:43:21 +00:00
|
|
|
|
State->buff = tmp;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
return 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
|
|
|
|
static gboolean DecodeHeader(unsigned char *BFH, unsigned char *BIH,
|
|
|
|
|
struct bmp_progressive_state *State,
|
|
|
|
|
GError **error)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
{
|
2004-02-20 21:23:42 +00:00
|
|
|
|
gint clrUsed;
|
|
|
|
|
|
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 is totally unrobust against bogus image data. */
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
2002-06-10 16:50:10 +00:00
|
|
|
|
if (State->BufferSize < lsb_32 (&BIH[0]) + 14) {
|
|
|
|
|
State->BufferSize = lsb_32 (&BIH[0]) + 14;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (!grow_buffer (State, error))
|
2002-03-05 22:44:27 +00:00
|
|
|
|
return FALSE;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
#if DUMPBIH
|
|
|
|
|
DumpBIH(BIH);
|
2004-02-20 21:23:42 +00:00
|
|
|
|
#endif
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2002-06-10 16:50:10 +00:00
|
|
|
|
State->Header.size = lsb_32 (&BIH[0]);
|
2001-05-28 18:28:16 +00:00
|
|
|
|
if (State->Header.size == 40) {
|
2002-06-10 16:50:10 +00:00
|
|
|
|
State->Header.width = lsb_32 (&BIH[4]);
|
|
|
|
|
State->Header.height = lsb_32 (&BIH[8]);
|
|
|
|
|
State->Header.depth = lsb_16 (&BIH[14]);
|
|
|
|
|
State->Compressed = lsb_32 (&BIH[16]);
|
2001-05-28 18:28:16 +00:00
|
|
|
|
} else if (State->Header.size == 12) {
|
2002-06-10 16:50:10 +00:00
|
|
|
|
State->Header.width = lsb_16 (&BIH[4]);
|
|
|
|
|
State->Header.height = lsb_16 (&BIH[6]);
|
|
|
|
|
State->Header.depth = lsb_16 (&BIH[10]);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->Compressed = BI_RGB;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("BMP image has unsupported header size"));
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2004-08-13 02:26:57 +00:00
|
|
|
|
if (State->Header.size == 12)
|
|
|
|
|
clrUsed = 1 << State->Header.depth;
|
|
|
|
|
else
|
|
|
|
|
clrUsed = (int) (BIH[35] << 24) + (BIH[34] << 16) + (BIH[33] << 8) + (BIH[32]);
|
|
|
|
|
|
2004-02-20 21:23:42 +00:00
|
|
|
|
if (clrUsed != 0)
|
|
|
|
|
State->Header.n_colors = clrUsed;
|
|
|
|
|
else
|
|
|
|
|
State->Header.n_colors = 1 << State->Header.depth;
|
|
|
|
|
|
|
|
|
|
if (State->Header.n_colors > 1 << State->Header.depth) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("BMP image has bogus header data"));
|
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
State->Type = State->Header.depth; /* This may be less trivial someday */
|
1999-11-24 21:12:24 +00:00
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
/* Negative heights indicates bottom-down pixelorder */
|
1999-11-24 21:12:24 +00:00
|
|
|
|
if (State->Header.height < 0) {
|
|
|
|
|
State->Header.height = -State->Header.height;
|
|
|
|
|
State->Header.Negative = 1;
|
|
|
|
|
}
|
|
|
|
|
if (State->Header.width < 0) {
|
|
|
|
|
State->Header.width = -State->Header.width;
|
|
|
|
|
State->Header.Negative = 0;
|
|
|
|
|
}
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
if (State->Header.width == 0 || State->Header.height == 0 ||
|
|
|
|
|
(State->Compressed == BI_RLE4 && State->Type != 4) ||
|
|
|
|
|
(State->Compressed == BI_RLE8 && State->Type != 8) ||
|
2001-11-29 00:13:02 +00:00
|
|
|
|
(State->Compressed == BI_BITFIELDS && !(State->Type == 16 || State->Type == 32)) ||
|
|
|
|
|
State->Compressed > BI_BITFIELDS) {
|
2001-05-28 18:28:16 +00:00
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("BMP image has bogus header data"));
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
if (State->Type == 32)
|
|
|
|
|
State->LineWidth = State->Header.width * 4;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
else if (State->Type == 24)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
State->LineWidth = State->Header.width * 3;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
else if (State->Type == 16)
|
|
|
|
|
State->LineWidth = State->Header.width * 2;
|
|
|
|
|
else if (State->Type == 8)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
State->LineWidth = State->Header.width * 1;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
else if (State->Type == 4)
|
1999-12-04 18:17:52 +00:00
|
|
|
|
State->LineWidth = (State->Header.width + 1) / 2;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
else if (State->Type == 1) {
|
1999-11-21 21:28:28 +00:00
|
|
|
|
State->LineWidth = State->Header.width / 8;
|
|
|
|
|
if ((State->Header.width & 7) != 0)
|
|
|
|
|
State->LineWidth++;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("BMP image has bogus header data"));
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
return FALSE;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
}
|
1999-11-24 21:12:24 +00:00
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
/* Pad to a 32 bit boundary */
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (((State->LineWidth % 4) > 0)
|
|
|
|
|
&& (State->Compressed == BI_RGB || State->Compressed == BI_BITFIELDS))
|
1999-11-24 21:12:24 +00:00
|
|
|
|
State->LineWidth = (State->LineWidth / 4) * 4 + 4;
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
if (State->pixbuf == NULL) {
|
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) {
|
|
|
|
|
State->read_state = READ_STATE_DONE;
|
|
|
|
|
State->BufferSize = 0;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (State->Type == 32 ||
|
|
|
|
|
State->Compressed == BI_RLE4 ||
|
|
|
|
|
State->Compressed == BI_RLE8)
|
1999-12-04 18:17:52 +00:00
|
|
|
|
State->pixbuf =
|
2004-01-07 00:26:58 +00:00
|
|
|
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
|
|
|
|
|
(gint) State->Header.width,
|
|
|
|
|
(gint) State->Header.height);
|
1999-12-04 18:17:52 +00:00
|
|
|
|
else
|
|
|
|
|
State->pixbuf =
|
2004-01-07 00:26:58 +00:00
|
|
|
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
|
|
|
|
|
(gint) State->Header.width,
|
|
|
|
|
(gint) State->Header.height);
|
|
|
|
|
|
|
|
|
|
if (State->pixbuf == NULL) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Not enough memory to load bitmap image"));
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
2004-01-07 00:26:58 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
if (State->prepared_func != NULL)
|
|
|
|
|
/* Notify the client that we are ready to go */
|
2001-05-07 15:58:47 +00:00
|
|
|
|
(*State->prepared_func) (State->pixbuf, NULL, State->user_data);
|
2004-01-07 00:26:58 +00:00
|
|
|
|
|
|
|
|
|
/* make all pixels initially transparent */
|
|
|
|
|
if (State->Compressed == BI_RLE4 || State->Compressed == BI_RLE8) {
|
|
|
|
|
memset (State->pixbuf->pixels, 0, State->pixbuf->rowstride * State->Header.height);
|
|
|
|
|
State->compr.p = State->pixbuf->pixels
|
|
|
|
|
+ State->pixbuf->rowstride * (State->Header.height- 1);
|
|
|
|
|
}
|
1999-11-21 21:28:28 +00:00
|
|
|
|
}
|
2002-07-02 17:54:06 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
State->BufferDone = 0;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (State->Type <= 8) {
|
|
|
|
|
State->read_state = READ_STATE_PALETTE;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
State->BufferSize = lsb_32 (&BFH[10]) - 14 - State->Header.size;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
} else if (State->Compressed == BI_RGB) {
|
|
|
|
|
State->read_state = READ_STATE_DATA;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
State->BufferSize = State->LineWidth;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
} else if (State->Compressed == BI_BITFIELDS) {
|
|
|
|
|
State->read_state = READ_STATE_BITMASKS;
|
|
|
|
|
State->BufferSize = 12;
|
2002-03-12 19:49:03 +00:00
|
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("BMP image has bogus header data"));
|
|
|
|
|
State->read_state = READ_STATE_ERROR;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (!grow_buffer (State, error))
|
|
|
|
|
return FALSE;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
static gboolean DecodeColormap (guchar *buff,
|
|
|
|
|
struct bmp_progressive_state *State,
|
|
|
|
|
GError **error)
|
2001-05-28 18:28:16 +00:00
|
|
|
|
{
|
|
|
|
|
gint i;
|
2004-02-20 21:23:42 +00:00
|
|
|
|
gint samples;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
g_assert (State->read_state == READ_STATE_PALETTE);
|
|
|
|
|
|
2004-02-20 21:23:42 +00:00
|
|
|
|
samples = (State->Header.size == 12 ? 3 : 4);
|
|
|
|
|
if (State->BufferSize < State->Header.n_colors * samples) {
|
|
|
|
|
State->BufferSize = State->Header.n_colors * samples;
|
|
|
|
|
if (!grow_buffer (State, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
State->Colormap = g_malloc ((1 << State->Header.depth) * sizeof (*State->Colormap));
|
2004-02-20 21:23:42 +00:00
|
|
|
|
for (i = 0; i < State->Header.n_colors; i++)
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
|
|
|
|
{
|
2004-02-20 21:23:42 +00:00
|
|
|
|
State->Colormap[i][0] = buff[i * samples];
|
|
|
|
|
State->Colormap[i][1] = buff[i * samples + 1];
|
|
|
|
|
State->Colormap[i][2] = buff[i * samples + 2];
|
2002-07-02 17:54:06 +00:00
|
|
|
|
#ifdef DUMPCMAP
|
|
|
|
|
g_print ("color %d %x %x %x\n", i,
|
|
|
|
|
State->Colormap[i][0],
|
|
|
|
|
State->Colormap[i][1],
|
|
|
|
|
State->Colormap[i][2]);
|
|
|
|
|
#endif
|
2001-05-28 18:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
State->read_state = READ_STATE_DATA;
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
State->BufferDone = 0;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (!(State->Compressed == BI_RGB || State->Compressed == BI_BITFIELDS))
|
2001-05-28 18:28:16 +00:00
|
|
|
|
State->BufferSize = 2;
|
|
|
|
|
else
|
|
|
|
|
State->BufferSize = State->LineWidth;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
|
|
|
|
|
if (!grow_buffer (State, error))
|
|
|
|
|
return FALSE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
return TRUE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finds the lowest set bit and the number of set bits */
|
|
|
|
|
static void
|
|
|
|
|
find_bits (int n, int *lowest, int *n_set)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
*n_set = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 31; i >= 0; i--)
|
|
|
|
|
if (n & (1 << i)) {
|
|
|
|
|
*lowest = i;
|
|
|
|
|
(*n_set)++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Decodes the 3 shorts that follow for the bitmasks for BI_BITFIELDS coding */
|
2002-07-02 17:54:06 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
decode_bitmasks (guchar *buf,
|
|
|
|
|
struct bmp_progressive_state *State,
|
|
|
|
|
GError **error)
|
2001-11-29 00:13:02 +00:00
|
|
|
|
{
|
|
|
|
|
State->r_mask = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
|
|
|
|
|
buf += 4;
|
|
|
|
|
|
|
|
|
|
State->g_mask = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
|
|
|
|
|
buf += 4;
|
|
|
|
|
|
|
|
|
|
State->b_mask = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
|
|
|
|
|
|
|
|
|
|
find_bits (State->r_mask, &State->r_shift, &State->r_bits);
|
|
|
|
|
find_bits (State->g_mask, &State->g_shift, &State->g_bits);
|
|
|
|
|
find_bits (State->b_mask, &State->b_shift, &State->b_bits);
|
|
|
|
|
|
|
|
|
|
if (State->r_bits == 0 || State->g_bits == 0 || State->b_bits == 0) {
|
|
|
|
|
State->r_mask = 0x7c00;
|
|
|
|
|
State->r_shift = 10;
|
|
|
|
|
State->g_mask = 0x03e0;
|
|
|
|
|
State->g_shift = 5;
|
|
|
|
|
State->b_mask = 0x001f;
|
|
|
|
|
State->b_shift = 0;
|
|
|
|
|
|
|
|
|
|
State->r_bits = State->g_bits = State->b_bits = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State->read_state = READ_STATE_DATA;
|
|
|
|
|
State->BufferDone = 0;
|
|
|
|
|
State->BufferSize = State->LineWidth;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (!grow_buffer (State, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/*
|
1999-11-21 21:28:28 +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__bmp_image_begin_load(GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepared_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc updated_func,
|
2001-05-07 15:58:47 +00:00
|
|
|
|
gpointer user_data,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
GError **error)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
{
|
|
|
|
|
struct bmp_progressive_state *context;
|
2004-02-20 21:23:42 +00:00
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
context = g_new0(struct bmp_progressive_state, 1);
|
2004-01-07 00:26:58 +00:00
|
|
|
|
context->size_func = size_func;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
context->prepared_func = prepared_func;
|
|
|
|
|
context->updated_func = updated_func;
|
|
|
|
|
context->user_data = user_data;
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
context->read_state = READ_STATE_HEADERS;
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->BufferSize = 26;
|
|
|
|
|
context->buff = g_malloc(26);
|
|
|
|
|
context->BufferDone = 0;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
/* 14 for the BitmapFileHeader, 12 for the BitmapImageHeader */
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap = NULL;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
context->Lines = 0;
|
|
|
|
|
|
|
|
|
|
context->Type = 0;
|
|
|
|
|
|
|
|
|
|
memset(&context->Header, 0, sizeof(struct headerpair));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
memset(&context->compr, 0, sizeof(struct bmp_compression_state));
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context->pixbuf = NULL;
|
2004-02-20 21:23:42 +00:00
|
|
|
|
|
1999-11-21 21:28:28 +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__bmp_image_stop_load(gpointer data, GError **error)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
{
|
|
|
|
|
struct bmp_progressive_state *context =
|
|
|
|
|
(struct bmp_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
|
2001-11-29 00:13:02 +00:00
|
|
|
|
*/
|
2004-02-20 21:23:42 +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-21 21:28:28 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
if (context->Colormap != NULL)
|
|
|
|
|
g_free(context->Colormap);
|
1999-11-21 21:28:28 +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-21 21:28:28 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
g_free(context->buff);
|
1999-11-21 21:28:28 +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-21 21:28:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
/*
|
|
|
|
|
The OneLineXX functions are called when 1 line worth of data is present.
|
|
|
|
|
OneLine24 is the 24 bpp-version.
|
|
|
|
|
*/
|
|
|
|
|
static void OneLine32(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
2001-11-29 01:39:34 +00:00
|
|
|
|
int i;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
guchar *pixels;
|
|
|
|
|
guchar *src;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (!context->Header.Negative)
|
|
|
|
|
pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
|
1999-12-04 18:17:52 +00:00
|
|
|
|
else
|
2001-11-29 00:13:02 +00:00
|
|
|
|
pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride * context->Lines);
|
|
|
|
|
|
|
|
|
|
src = context->buff;
|
|
|
|
|
|
|
|
|
|
if (context->Compressed == BI_BITFIELDS) {
|
|
|
|
|
int r_lshift, r_rshift;
|
|
|
|
|
int g_lshift, g_rshift;
|
|
|
|
|
int b_lshift, b_rshift;
|
|
|
|
|
|
|
|
|
|
r_lshift = 8 - context->r_bits;
|
|
|
|
|
g_lshift = 8 - context->g_bits;
|
|
|
|
|
b_lshift = 8 - context->b_bits;
|
|
|
|
|
|
|
|
|
|
r_rshift = context->r_bits - r_lshift;
|
|
|
|
|
g_rshift = context->g_bits - g_lshift;
|
|
|
|
|
b_rshift = context->b_bits - b_lshift;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
for (i = 0; i < context->Header.width; i++) {
|
|
|
|
|
int v, r, g, b;
|
|
|
|
|
|
|
|
|
|
v = src[0] | (src[1] << 8) | (src[2] << 16);
|
|
|
|
|
|
|
|
|
|
r = (v & context->r_mask) >> context->r_shift;
|
|
|
|
|
g = (v & context->g_mask) >> context->g_shift;
|
|
|
|
|
b = (v & context->b_mask) >> context->b_shift;
|
|
|
|
|
|
|
|
|
|
*pixels++ = (r << r_lshift) | (r >> r_rshift);
|
|
|
|
|
*pixels++ = (g << g_lshift) | (g >> g_rshift);
|
|
|
|
|
*pixels++ = (b << b_lshift) | (b >> b_rshift);
|
2004-03-05 21:20:28 +00:00
|
|
|
|
*pixels++ = 0xff;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
|
|
|
|
src += 4;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
for (i = 0; i < context->Header.width; i++) {
|
|
|
|
|
*pixels++ = src[2];
|
|
|
|
|
*pixels++ = src[1];
|
|
|
|
|
*pixels++ = src[0];
|
2004-03-05 21:20:28 +00:00
|
|
|
|
*pixels++ = 0xff;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
|
|
|
|
src += 4;
|
|
|
|
|
}
|
1999-12-04 18:17:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
static void OneLine24(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
if (context->Header.Negative == 0)
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
(context->Header.height - context->Lines - 1));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
else
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
context->Lines);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
while (X < context->Header.width) {
|
2001-05-28 18:28:16 +00:00
|
|
|
|
Pixels[X * 3 + 0] = context->buff[X * 3 + 2];
|
|
|
|
|
Pixels[X * 3 + 1] = context->buff[X * 3 + 1];
|
|
|
|
|
Pixels[X * 3 + 2] = context->buff[X * 3 + 0];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
static void OneLine16(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
2001-11-29 00:13:02 +00:00
|
|
|
|
int i;
|
|
|
|
|
guchar *pixels;
|
|
|
|
|
guchar *src;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (!context->Header.Negative)
|
|
|
|
|
pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
|
2001-05-28 18:28:16 +00:00
|
|
|
|
else
|
2001-11-29 00:13:02 +00:00
|
|
|
|
pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride * context->Lines);
|
|
|
|
|
|
|
|
|
|
src = context->buff;
|
|
|
|
|
|
|
|
|
|
if (context->Compressed == BI_BITFIELDS) {
|
|
|
|
|
int r_lshift, r_rshift;
|
|
|
|
|
int g_lshift, g_rshift;
|
|
|
|
|
int b_lshift, b_rshift;
|
|
|
|
|
|
|
|
|
|
r_lshift = 8 - context->r_bits;
|
|
|
|
|
g_lshift = 8 - context->g_bits;
|
|
|
|
|
b_lshift = 8 - context->b_bits;
|
|
|
|
|
|
|
|
|
|
r_rshift = context->r_bits - r_lshift;
|
|
|
|
|
g_rshift = context->g_bits - g_lshift;
|
|
|
|
|
b_rshift = context->b_bits - b_lshift;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < context->Header.width; i++) {
|
|
|
|
|
int v, r, g, b;
|
|
|
|
|
|
|
|
|
|
v = (int) src[0] | ((int) src[1] << 8);
|
|
|
|
|
|
|
|
|
|
r = (v & context->r_mask) >> context->r_shift;
|
|
|
|
|
g = (v & context->g_mask) >> context->g_shift;
|
|
|
|
|
b = (v & context->b_mask) >> context->b_shift;
|
|
|
|
|
|
|
|
|
|
*pixels++ = (r << r_lshift) | (r >> r_rshift);
|
|
|
|
|
*pixels++ = (g << g_lshift) | (g >> g_rshift);
|
|
|
|
|
*pixels++ = (b << b_lshift) | (b >> b_rshift);
|
|
|
|
|
|
|
|
|
|
src += 2;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
for (i = 0; i < context->Header.width; i++) {
|
|
|
|
|
int v, r, g, b;
|
|
|
|
|
|
|
|
|
|
v = src[0] | (src[1] << 8);
|
|
|
|
|
|
|
|
|
|
r = (v >> 10) & 0x1f;
|
|
|
|
|
g = (v >> 5) & 0x1f;
|
|
|
|
|
b = v & 0x1f;
|
|
|
|
|
|
|
|
|
|
*pixels++ = (r << 3) | (r >> 2);
|
|
|
|
|
*pixels++ = (g << 3) | (g >> 2);
|
|
|
|
|
*pixels++ = (b << 3) | (b >> 2);
|
2002-07-02 17:54:06 +00:00
|
|
|
|
|
|
|
|
|
src += 2;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
}
|
2001-05-28 18:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
static void OneLine8(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
if (context->Header.Negative == 0)
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
(context->Header.height - context->Lines - 1));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
else
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
context->Lines);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
Pixels[X * 3 + 0] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[context->buff[X]][2];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
Pixels[X * 3 + 1] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[context->buff[X]][1];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
Pixels[X * 3 + 2] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[context->buff[X]][0];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
static void OneLine4(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
|
|
|
|
if (context->Header.Negative == 0)
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
(context->Header.height - context->Lines - 1));
|
1999-12-04 18:17:52 +00:00
|
|
|
|
else
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
context->Lines);
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
|
|
|
|
while (X < context->Header.width) {
|
|
|
|
|
guchar Pix;
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
Pix = context->buff[X / 2];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
|
|
|
|
|
Pixels[X * 3 + 0] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix >> 4][2];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
Pixels[X * 3 + 1] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix >> 4][1];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
Pixels[X * 3 + 2] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix >> 4][0];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
X++;
|
|
|
|
|
if (X < context->Header.width) {
|
|
|
|
|
/* Handle the other 4 bit pixel only when there is one */
|
|
|
|
|
Pixels[X * 3 + 0] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix & 15][2];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
Pixels[X * 3 + 1] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix & 15][1];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
Pixels[X * 3 + 2] =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->Colormap[Pix & 15][0];
|
1999-12-04 18:17:52 +00:00
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
static void OneLine1(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
|
|
|
|
gint X;
|
|
|
|
|
guchar *Pixels;
|
|
|
|
|
|
|
|
|
|
X = 0;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
if (context->Header.Negative == 0)
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
(context->Header.height - context->Lines - 1));
|
1999-11-24 21:12:24 +00:00
|
|
|
|
else
|
2000-04-11 07:03:25 +00:00
|
|
|
|
Pixels = (context->pixbuf->pixels +
|
|
|
|
|
context->pixbuf->rowstride *
|
|
|
|
|
context->Lines);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
while (X < context->Header.width) {
|
1999-12-04 18:17:52 +00:00
|
|
|
|
gint Bit;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
Bit = (context->buff[X / 8]) >> (7 - (X & 7));
|
1999-11-21 21:28:28 +00:00
|
|
|
|
Bit = Bit & 1;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
Pixels[X * 3 + 0] = context->Colormap[Bit][2];
|
|
|
|
|
Pixels[X * 3 + 1] = context->Colormap[Bit][1];
|
|
|
|
|
Pixels[X * 3 + 2] = context->Colormap[Bit][0];
|
1999-11-21 21:28:28 +00:00
|
|
|
|
X++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void OneLine(struct bmp_progressive_state *context)
|
|
|
|
|
{
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->BufferDone = 0;
|
1999-11-24 21:12:24 +00:00
|
|
|
|
if (context->Lines >= context->Header.height)
|
|
|
|
|
return;
|
|
|
|
|
|
1999-12-04 18:17:52 +00:00
|
|
|
|
if (context->Type == 32)
|
|
|
|
|
OneLine32(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else if (context->Type == 24)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
OneLine24(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else if (context->Type == 16)
|
2001-05-28 18:28:16 +00:00
|
|
|
|
OneLine16(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else if (context->Type == 8)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
OneLine8(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else if (context->Type == 4)
|
1999-12-04 18:17:52 +00:00
|
|
|
|
OneLine4(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else if (context->Type == 1)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
OneLine1(context);
|
2001-11-29 00:13:02 +00:00
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
context->Lines++;
|
|
|
|
|
|
|
|
|
|
if (context->updated_func != NULL) {
|
|
|
|
|
(*context->updated_func) (context->pixbuf,
|
|
|
|
|
0,
|
2002-09-27 21:37:30 +00:00
|
|
|
|
(context->Header.Negative ?
|
|
|
|
|
(context->Lines - 1) :
|
|
|
|
|
(context->Header.height - context->Lines)),
|
1999-11-21 21:28:28 +00:00
|
|
|
|
context->Header.width,
|
2002-09-27 21:37:30 +00:00
|
|
|
|
1,
|
2000-01-05 23:06:13 +00:00
|
|
|
|
context->user_data);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
#define NEUTRAL 0
|
|
|
|
|
#define ENCODED 1
|
|
|
|
|
#define ESCAPE 2
|
|
|
|
|
#define DELTA_X 3
|
|
|
|
|
#define DELTA_Y 4
|
|
|
|
|
#define ABSOLUTE 5
|
|
|
|
|
#define SKIP 6
|
|
|
|
|
|
|
|
|
|
#define END_OF_LINE 0
|
|
|
|
|
#define END_OF_BITMAP 1
|
|
|
|
|
#define DELTA 2
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
DoCompressed(struct bmp_progressive_state *context, GError **error)
|
1999-12-04 18:17:52 +00:00
|
|
|
|
{
|
2002-07-02 17:54:06 +00:00
|
|
|
|
gint i, j;
|
|
|
|
|
gint y;
|
|
|
|
|
guchar c;
|
|
|
|
|
gint idx;
|
|
|
|
|
|
2004-08-20 17:59:24 +00:00
|
|
|
|
/* context->compr.y might be past the last line because we are
|
|
|
|
|
* on padding past the end of a valid data, or we might have hit
|
|
|
|
|
* out-of-bounds data. Either way we just eat-and-ignore the
|
|
|
|
|
* rest of the file. Doing the check only here and not when
|
|
|
|
|
* we change y below is fine since BufferSize is always 2 here
|
|
|
|
|
* and the BMP file format always starts new data on 16-bit
|
|
|
|
|
* boundaries.
|
|
|
|
|
*/
|
|
|
|
|
if (context->compr.y >= context->Header.height) {
|
|
|
|
|
context->BufferDone = 0;
|
2002-07-02 17:54:06 +00:00
|
|
|
|
return TRUE;
|
2004-08-20 17:59:24 +00:00
|
|
|
|
}
|
2001-05-28 18:28:16 +00:00
|
|
|
|
|
2002-07-02 17:54:06 +00:00
|
|
|
|
y = context->compr.y;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < context->BufferSize; i++) {
|
|
|
|
|
c = context->buff[i];
|
|
|
|
|
switch (context->compr.phase) {
|
|
|
|
|
case NEUTRAL:
|
|
|
|
|
if (c) {
|
|
|
|
|
context->compr.run = c;
|
|
|
|
|
context->compr.phase = ENCODED;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
context->compr.phase = ESCAPE;
|
|
|
|
|
break;
|
|
|
|
|
case ENCODED:
|
|
|
|
|
for (j = 0; j < context->compr.run; j++) {
|
|
|
|
|
if (context->Compressed == BI_RLE8)
|
|
|
|
|
idx = c;
|
|
|
|
|
else if (j & 1)
|
|
|
|
|
idx = c & 0x0f;
|
|
|
|
|
else
|
|
|
|
|
idx = (c >> 4) & 0x0f;
|
|
|
|
|
if (context->compr.x < context->Header.width) {
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][2];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][1];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][0];
|
|
|
|
|
*context->compr.p++ = 0xff;
|
|
|
|
|
context->compr.x++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
|
|
|
|
case ESCAPE:
|
|
|
|
|
switch (c) {
|
|
|
|
|
case END_OF_LINE:
|
|
|
|
|
context->compr.x = 0;
|
|
|
|
|
context->compr.y++;
|
|
|
|
|
context->compr.p = context->pixbuf->pixels
|
|
|
|
|
+ (context->pixbuf->rowstride * (context->Header.height - context->compr.y - 1))
|
|
|
|
|
+ (4 * context->compr.x);
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
|
|
|
|
case END_OF_BITMAP:
|
|
|
|
|
context->compr.x = 0;
|
|
|
|
|
context->compr.y = context->Header.height;
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
|
|
|
|
case DELTA:
|
|
|
|
|
context->compr.phase = DELTA_X;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
context->compr.run = c;
|
|
|
|
|
context->compr.count = 0;
|
|
|
|
|
context->compr.phase = ABSOLUTE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DELTA_X:
|
|
|
|
|
context->compr.x += c;
|
|
|
|
|
context->compr.phase = DELTA_Y;
|
|
|
|
|
break;
|
|
|
|
|
case DELTA_Y:
|
|
|
|
|
context->compr.y += c;
|
|
|
|
|
context->compr.p = context->pixbuf->pixels
|
|
|
|
|
+ (context->pixbuf->rowstride * (context->Header.height - context->compr.y - 1))
|
|
|
|
|
+ (4 * context->compr.x);
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
|
|
|
|
case ABSOLUTE:
|
|
|
|
|
if (context->Compressed == BI_RLE8) {
|
|
|
|
|
idx = c;
|
|
|
|
|
if (context->compr.x < context->Header.width) {
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][2];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][1];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][0];
|
|
|
|
|
*context->compr.p++ = 0xff;
|
|
|
|
|
context->compr.x++;
|
|
|
|
|
}
|
|
|
|
|
context->compr.count++;
|
|
|
|
|
|
|
|
|
|
if (context->compr.count == context->compr.run) {
|
|
|
|
|
if (context->compr.run & 1)
|
|
|
|
|
context->compr.phase = SKIP;
|
|
|
|
|
else
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
|
if (context->compr.count & 1)
|
|
|
|
|
idx = c & 0x0f;
|
|
|
|
|
else
|
|
|
|
|
idx = (c >> 4) & 0x0f;
|
|
|
|
|
if (context->compr.x < context->Header.width) {
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][2];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][1];
|
|
|
|
|
*context->compr.p++ = context->Colormap[idx][0];
|
|
|
|
|
*context->compr.p++ = 0xff;
|
|
|
|
|
context->compr.x++;
|
|
|
|
|
}
|
|
|
|
|
context->compr.count++;
|
|
|
|
|
|
|
|
|
|
if (context->compr.count == context->compr.run) {
|
|
|
|
|
if ((context->compr.run & 3) == 1
|
|
|
|
|
|| (context->compr.run & 3) == 2)
|
|
|
|
|
context->compr.phase = SKIP;
|
|
|
|
|
else
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SKIP:
|
|
|
|
|
context->compr.phase = NEUTRAL;
|
|
|
|
|
break;
|
2000-03-06 08:53:57 +00:00
|
|
|
|
}
|
1999-12-04 18:17:52 +00:00
|
|
|
|
}
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (context->updated_func != NULL) {
|
|
|
|
|
if (context->compr.y > y)
|
|
|
|
|
(*context->updated_func) (context->pixbuf,
|
|
|
|
|
0,
|
|
|
|
|
y,
|
|
|
|
|
context->Header.width,
|
|
|
|
|
context->compr.y - y,
|
|
|
|
|
context->user_data);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->BufferDone = 0;
|
|
|
|
|
return TRUE;
|
1999-12-04 18:17:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
/*
|
|
|
|
|
* context - from image_begin_load
|
|
|
|
|
* buf - new image data
|
|
|
|
|
* size - length of new image data
|
|
|
|
|
*
|
2004-02-20 21:23:42 +00:00
|
|
|
|
* append image data onto incrementally built output image
|
1999-11-21 21:28:28 +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__bmp_image_load_increment(gpointer data,
|
|
|
|
|
const guchar * buf,
|
|
|
|
|
guint size,
|
|
|
|
|
GError **error)
|
1999-11-21 21:28:28 +00:00
|
|
|
|
{
|
|
|
|
|
struct bmp_progressive_state *context =
|
|
|
|
|
(struct bmp_progressive_state *) data;
|
|
|
|
|
|
|
|
|
|
gint BytesToCopy;
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (context->read_state == READ_STATE_DONE)
|
|
|
|
|
return TRUE;
|
|
|
|
|
else if (context->read_state == READ_STATE_ERROR)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
while (size > 0) {
|
2001-11-29 00:13:02 +00:00
|
|
|
|
if (context->BufferDone < context->BufferSize) { /* We still
|
1999-11-21 21:28:28 +00:00
|
|
|
|
have headerbytes to do */
|
|
|
|
|
BytesToCopy =
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->BufferSize - context->BufferDone;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
if (BytesToCopy > size)
|
|
|
|
|
BytesToCopy = size;
|
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
memmove(context->buff + context->BufferDone,
|
2000-03-06 08:53:57 +00:00
|
|
|
|
buf, BytesToCopy);
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
size -= BytesToCopy;
|
|
|
|
|
buf += BytesToCopy;
|
2001-05-28 18:28:16 +00:00
|
|
|
|
context->BufferDone += BytesToCopy;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
|
2001-05-28 18:28:16 +00:00
|
|
|
|
if (context->BufferDone != context->BufferSize)
|
|
|
|
|
break;
|
1999-11-21 21:28:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-29 00:13:02 +00:00
|
|
|
|
switch (context->read_state) {
|
|
|
|
|
case READ_STATE_HEADERS:
|
2001-11-29 01:39:34 +00:00
|
|
|
|
if (!DecodeHeader (context->buff,
|
|
|
|
|
context->buff + 14, context,
|
|
|
|
|
error))
|
2001-05-28 18:28:16 +00:00
|
|
|
|
return FALSE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case READ_STATE_PALETTE:
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (!DecodeColormap (context->buff, context, error))
|
|
|
|
|
return FALSE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case READ_STATE_BITMASKS:
|
2002-07-02 17:54:06 +00:00
|
|
|
|
if (!decode_bitmasks (context->buff, context, error))
|
|
|
|
|
return FALSE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case READ_STATE_DATA:
|
|
|
|
|
if (context->Compressed == BI_RGB || context->Compressed == BI_BITFIELDS)
|
|
|
|
|
OneLine (context);
|
2002-07-02 17:54:06 +00:00
|
|
|
|
else if (!DoCompressed (context, error))
|
|
|
|
|
return FALSE;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
|
|
|
|
break;
|
2004-01-07 00:26:58 +00:00
|
|
|
|
case READ_STATE_DONE:
|
|
|
|
|
return TRUE;
|
|
|
|
|
break;
|
2001-11-29 00:13:02 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2001-05-28 18:28:16 +00:00
|
|
|
|
}
|
1999-11-21 21:28:28 +00:00
|
|
|
|
}
|
1999-07-08 16:04:16 +00:00
|
|
|
|
|
1999-11-21 21:28:28 +00:00
|
|
|
|
return TRUE;
|
1999-07-08 16:04:16 +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 (bmp, 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__bmp_image_begin_load;
|
|
|
|
|
module->stop_load = gdk_pixbuf__bmp_image_stop_load;
|
|
|
|
|
module->load_increment = gdk_pixbuf__bmp_image_load_increment;
|
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
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MODULE_ENTRY (bmp, fill_info) (GdkPixbufFormat *info)
|
|
|
|
|
{
|
|
|
|
|
static GdkPixbufModulePattern signature[] = {
|
|
|
|
|
{ "BM", NULL, 100 },
|
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
static gchar * mime_types[] = {
|
|
|
|
|
"image/bmp",
|
|
|
|
|
"image/x-bmp",
|
|
|
|
|
"image/x-MS-bmp",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
static gchar * extensions[] = {
|
|
|
|
|
"bmp",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
info->name = "bmp";
|
|
|
|
|
info->signature = signature;
|
|
|
|
|
info->description = N_("The BMP image format");
|
|
|
|
|
info->mime_types = mime_types;
|
|
|
|
|
info->extensions = extensions;
|
|
|
|
|
info->flags = 0;
|
2004-07-08 03:56:36 +00:00
|
|
|
|
info->license = "LGPL";
|
2002-10-03 22:39:51 +00:00
|
|
|
|
}
|
|
|
|
|
|