summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md21
-rw-r--r--gdk-pixbuf/gdk-pixbuf-data.c6
-rw-r--r--gdk-pixbuf/gdk-pixbuf-private.h41
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c133
-rw-r--r--gdk-pixbuf/gdk-pixdata.c29
-rw-r--r--gdk-pixbuf/io-ani-animation.c1
-rw-r--r--gdk-pixbuf/io-ani-animation.h2
-rw-r--r--gdk-pixbuf/io-ani.c1
-rw-r--r--gdk-pixbuf/io-bmp.c84
-rw-r--r--gdk-pixbuf/io-gif-animation.c1
-rw-r--r--gdk-pixbuf/io-gif.c3
-rw-r--r--gdk-pixbuf/io-icns.c6
-rw-r--r--gdk-pixbuf/io-ico.c80
-rw-r--r--gdk-pixbuf/io-jasper.c5
-rw-r--r--gdk-pixbuf/io-jpeg.c19
-rw-r--r--gdk-pixbuf/io-png.c33
-rw-r--r--gdk-pixbuf/io-pnm.c11
-rw-r--r--gdk-pixbuf/io-qtif.c2
-rw-r--r--gdk-pixbuf/io-tga.c36
-rw-r--r--gdk-pixbuf/io-tiff.c43
-rw-r--r--gdk-pixbuf/io-xbm.c4
-rw-r--r--gdk-pixbuf/io-xpm.c15
22 files changed, 373 insertions, 203 deletions
diff --git a/README.md b/README.md
index 484dfc28d..6b3bc74e3 100644
--- a/README.md
+++ b/README.md
@@ -63,6 +63,27 @@ You can use the `--prefix` argument to control the installation prefix.
You can also use `meson configure` from within the build directory to
check the current build configuration, and change its options.
+#### Build options
+
+You can specify the following options in the command line to `meson`:
+
+* `-Djasper=true` - Enable support for JPEG2000. This requires
+ libjasper's development files to be installed.
+
+* `-Ddocs=true` - Build the API reference documentation. This
+ requires `gtk-doc` to be installed.
+
+* `-Drelocatable=true` - Enable application bundle relocation support.
+
+For a complete list of build-time options, see the file
+[`meson_options.txt`](meson_options.txt). You can read about Meson
+options in general [in the Meson manual](http://mesonbuild.com/Build-options.html).
+
+## Running tests
+
+You can run the test suite by running `meson test -C _build`, where
+`_build` is the build directory you used during the build stage.
+
## License
GdkPixbuf is released under the terms of the GNU Lesser General Public
diff --git a/gdk-pixbuf/gdk-pixbuf-data.c b/gdk-pixbuf/gdk-pixbuf-data.c
index 769ead337..cd968d4ae 100644
--- a/gdk-pixbuf/gdk-pixbuf-data.c
+++ b/gdk-pixbuf/gdk-pixbuf-data.c
@@ -77,9 +77,9 @@ gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean
"rowstride", rowstride,
"pixels", data,
NULL);
-
- pixbuf->destroy_fn = destroy_fn;
- pixbuf->destroy_fn_data = destroy_fn_data;
+ g_assert (pixbuf->storage == STORAGE_PIXELS);
+ pixbuf->s.pixels.destroy_fn = destroy_fn;
+ pixbuf->s.pixels.destroy_fn_data = destroy_fn_data;
return pixbuf;
}
diff --git a/gdk-pixbuf/gdk-pixbuf-private.h b/gdk-pixbuf/gdk-pixbuf-private.h
index cd26895f5..79ccf1531 100644
--- a/gdk-pixbuf/gdk-pixbuf-private.h
+++ b/gdk-pixbuf/gdk-pixbuf-private.h
@@ -46,15 +46,29 @@ typedef struct _GdkPixbufClass GdkPixbufClass;
#define GDK_IS_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF))
#define GDK_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF, GdkPixbufClass))
-/* Helper macros to convert between density units */
-#define DPI_TO_DPM(value) ((int) round ((value) * 1000 / 25.4))
-#define DPI_TO_DPCM(value) ((int) round ((value) / 2.54))
-#define DPM_TO_DPI(value) ((int) round ((value) * 25.4 / 1000))
-#define DPCM_TO_DPI(value) ((int) round ((value) * 2.54))
-
/* Default fill color */
#define DEFAULT_FILL_COLOR 0x979899ff
+typedef enum {
+ STORAGE_PIXELS,
+ STORAGE_BYTES
+} Storage;
+
+typedef struct {
+ /* The pixel array */
+ guchar *pixels;
+
+ /* Destroy notification function; it is supposed to free the pixel array */
+ GdkPixbufDestroyNotify destroy_fn;
+
+ /* User data for the destroy notification function */
+ gpointer destroy_fn_data;
+} Pixels;
+
+typedef struct {
+ GBytes *bytes;
+} Bytes;
+
/* Private part of the GdkPixbuf structure */
struct _GdkPixbuf {
GObject parent_instance;
@@ -74,17 +88,12 @@ struct _GdkPixbuf {
/* Offset between rows */
int rowstride;
- /* The pixel array */
- guchar *pixels;
-
- /* Destroy notification function; it is supposed to free the pixel array */
- GdkPixbufDestroyNotify destroy_fn;
+ Storage storage;
- /* User data for the destroy notification function */
- gpointer destroy_fn_data;
-
- /* Replaces "pixels" member (and destroy notify) */
- GBytes *bytes;
+ struct {
+ Pixels pixels;
+ Bytes bytes;
+ } s;
/* Do we have an alpha channel? */
guint has_alpha : 1;
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 8f220f44b..1c7fbee64 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -265,14 +265,42 @@ gdk_pixbuf_class_init (GdkPixbufClass *klass)
}
static void
+free_pixels (GdkPixbuf *pixbuf)
+{
+ g_assert (pixbuf->storage == STORAGE_PIXELS);
+
+ if (pixbuf->s.pixels.pixels && pixbuf->s.pixels.destroy_fn) {
+ (* pixbuf->s.pixels.destroy_fn) (pixbuf->s.pixels.pixels, pixbuf->s.pixels.destroy_fn_data);
+ }
+
+ pixbuf->s.pixels.pixels = NULL;
+}
+
+static void
+free_bytes (GdkPixbuf *pixbuf)
+{
+ g_assert (pixbuf->storage == STORAGE_BYTES);
+
+ g_clear_pointer (&pixbuf->s.bytes.bytes, g_bytes_unref);
+}
+
+static void
gdk_pixbuf_finalize (GObject *object)
{
GdkPixbuf *pixbuf = GDK_PIXBUF (object);
-
- if (pixbuf->pixels && pixbuf->destroy_fn)
- (* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
- g_clear_pointer (&pixbuf->bytes, g_bytes_unref);
+ switch (pixbuf->storage) {
+ case STORAGE_PIXELS:
+ free_pixels (pixbuf);
+ break;
+
+ case STORAGE_BYTES:
+ free_bytes (pixbuf);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
G_OBJECT_CLASS (gdk_pixbuf_parent_class)->finalize (object);
}
@@ -688,6 +716,32 @@ gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
return gdk_pixbuf_get_pixels_with_length (pixbuf, NULL);
}
+static void
+downgrade_to_pixels (const GdkPixbuf *pixbuf)
+{
+ switch (pixbuf->storage) {
+ case STORAGE_PIXELS:
+ return;
+
+ case STORAGE_BYTES: {
+ GdkPixbuf *mut_pixbuf = (GdkPixbuf *) pixbuf;
+ gsize len;
+ Pixels pixels;
+
+ pixels.pixels = g_bytes_unref_to_data (pixbuf->s.bytes.bytes, &len);
+ pixels.destroy_fn = free_buffer;
+ pixels.destroy_fn_data = NULL;
+
+ mut_pixbuf->storage = STORAGE_PIXELS;
+ mut_pixbuf->s.pixels = pixels;
+ break;
+ }
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
/**
* gdk_pixbuf_get_pixels_with_length: (rename-to gdk_pixbuf_get_pixels)
* @pixbuf: A pixbuf.
@@ -710,19 +764,13 @@ gdk_pixbuf_get_pixels_with_length (const GdkPixbuf *pixbuf,
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
- if (pixbuf->bytes) {
- GdkPixbuf *mut_pixbuf = (GdkPixbuf*)pixbuf;
- gsize len;
- mut_pixbuf->pixels = g_bytes_unref_to_data (pixbuf->bytes, &len);
- mut_pixbuf->bytes = NULL;
- mut_pixbuf->destroy_fn = free_buffer;
- mut_pixbuf->destroy_fn_data = NULL;
- }
+ downgrade_to_pixels (pixbuf);
+ g_assert (pixbuf->storage == STORAGE_PIXELS);
if (length)
*length = gdk_pixbuf_get_byte_length (pixbuf);
- return pixbuf->pixels;
+ return pixbuf->s.pixels.pixels;
}
/**
@@ -740,13 +788,20 @@ const guint8*
gdk_pixbuf_read_pixels (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
-
- if (pixbuf->bytes) {
+
+ switch (pixbuf->storage) {
+ case STORAGE_PIXELS:
+ return pixbuf->s.pixels.pixels;
+
+ case STORAGE_BYTES: {
gsize len;
/* Ignore len; callers know the size via other variables */
- return g_bytes_get_data (pixbuf->bytes, &len);
- } else {
- return pixbuf->pixels;
+ return g_bytes_get_data (pixbuf->s.bytes.bytes, &len);
+ }
+
+ default:
+ g_assert_not_reached ();
+ return NULL;
}
}
@@ -766,11 +821,16 @@ gdk_pixbuf_read_pixel_bytes (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
- if (pixbuf->bytes) {
- return g_bytes_ref (pixbuf->bytes);
- } else {
- return g_bytes_new (pixbuf->pixels,
+ switch (pixbuf->storage) {
+ case STORAGE_PIXELS:
+ return g_bytes_new (pixbuf->s.pixels.pixels,
gdk_pixbuf_get_byte_length (pixbuf));
+
+ case STORAGE_BYTES:
+ return g_bytes_ref (pixbuf->s.bytes.bytes);
+
+ default:
+ g_assert_not_reached ();
}
}
@@ -879,7 +939,6 @@ gdk_pixbuf_fill (GdkPixbuf *pixbuf,
guint w, h;
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
- g_return_if_fail (pixbuf->pixels || pixbuf->bytes);
if (pixbuf->width == 0 || pixbuf->height == 0)
return;
@@ -1206,13 +1265,31 @@ gdk_pixbuf_set_property (GObject *object,
notify = pixbuf->rowstride != g_value_get_int (value);
pixbuf->rowstride = g_value_get_int (value);
break;
+
+ /* The following two are a bit strange. Both PROP_PIXELS and PROP_PIXEL_BYTES are
+ * G_PARAM_CONSTRUCT_ONLY properties, which means that GObject will generate default
+ * values for any missing one and call us for *both*. So, we need to check whether the
+ * passed value is not NULL before actually setting pixbuf->storage.
+ */
case PROP_PIXELS:
- notify = pixbuf->pixels != (guchar *) g_value_get_pointer (value);
- pixbuf->pixels = (guchar *) g_value_get_pointer (value);
+ g_assert (pixbuf->s.pixels.pixels == NULL);
+ notify = pixbuf->s.pixels.pixels != (guchar *) g_value_get_pointer (value);
+ pixbuf->s.pixels.pixels = (guchar *) g_value_get_pointer (value);
+ pixbuf->s.pixels.destroy_fn = NULL;
+ pixbuf->s.pixels.destroy_fn_data = NULL;
+
+ if (pixbuf->s.pixels.pixels != NULL) {
+ pixbuf->storage = STORAGE_PIXELS;
+ }
break;
case PROP_PIXEL_BYTES:
- notify = pixbuf->bytes != g_value_get_boxed (value);
- pixbuf->bytes = g_value_dup_boxed (value);
+ g_assert (pixbuf->s.bytes.bytes == NULL);
+ notify = pixbuf->s.bytes.bytes != g_value_get_boxed (value);
+ pixbuf->s.bytes.bytes = g_value_dup_boxed (value);
+
+ if (pixbuf->s.bytes.bytes != NULL) {
+ pixbuf->storage = STORAGE_BYTES;
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1258,7 +1335,7 @@ gdk_pixbuf_get_property (GObject *object,
g_value_set_pointer (value, gdk_pixbuf_get_pixels (pixbuf));
break;
case PROP_PIXEL_BYTES:
- g_value_set_boxed (value, pixbuf->bytes);
+ g_value_set_boxed (value, gdk_pixbuf_read_pixel_bytes (pixbuf));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/gdk-pixbuf/gdk-pixdata.c b/gdk-pixbuf/gdk-pixdata.c
index af0424478..df1036a9a 100644
--- a/gdk-pixbuf/gdk-pixdata.c
+++ b/gdk-pixbuf/gdk-pixdata.c
@@ -249,25 +249,25 @@ gdk_pixdata_deserialize (GdkPixdata *pixdata,
}
static gboolean
-diff2_rgb (guint8 *ip)
+diff2_rgb (const guint8 *ip)
{
return ip[0] != ip[3] || ip[1] != ip[4] || ip[2] != ip[5];
}
static gboolean
-diff2_rgba (guint8 *ip)
+diff2_rgba (const guint8 *ip)
{
return ip[0] != ip[4] || ip[1] != ip[5] || ip[2] != ip[6] || ip[3] != ip[7];
}
-static guint8* /* dest buffer bound */
-rl_encode_rgbx (guint8 *bp, /* dest buffer */
- guint8 *ip, /* image pointer */
- guint8 *limit, /* image upper bound */
- guint n_ch)
+static guint8 * /* dest buffer bound */
+rl_encode_rgbx (guint8 *bp, /* dest buffer */
+ const guint8 *ip, /* image pointer */
+ const guint8 *limit, /* image upper bound */
+ guint n_ch)
{
- gboolean (*diff2_pix) (guint8 *) = n_ch > 3 ? diff2_rgba : diff2_rgb;
- guint8 *ilimit = limit - n_ch;
+ gboolean (*diff2_pix) (const guint8 *) = n_ch > 3 ? diff2_rgba : diff2_rgb;
+ const guint8 *ilimit = limit - n_ch;
while (ip < limit)
{
@@ -275,7 +275,7 @@ rl_encode_rgbx (guint8 *bp, /* dest buffer */
if (diff2_pix (ip))
{
- guint8 *s_ip = ip;
+ const guint8 *s_ip = ip;
guint l = 1;
ip += n_ch;
@@ -341,6 +341,7 @@ gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
{
gpointer free_me = NULL;
guint height, rowstride, encoding, bpp, length;
+ const guint8 *pixels = NULL;
guint8 *img_buffer;
g_return_val_if_fail (pixdata != NULL, NULL);
@@ -377,14 +378,16 @@ gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
buf, 0, 0);
}
else
- buf = (GdkPixbuf *)pixbuf;
+ buf = (GdkPixbuf *)pixbuf;
+
+ pixels = gdk_pixbuf_read_pixels (buf);
pad = rowstride;
pad = MAX (pad, 130 + n_bytes / 127);
data = g_new (guint8, pad + n_bytes);
free_me = data;
img_buffer = data;
img_buffer_end = rl_encode_rgbx (img_buffer,
- buf->pixels, buf->pixels + n_bytes,
+ pixels, pixels + n_bytes,
bpp);
length = img_buffer_end - img_buffer;
if (buf != pixbuf)
@@ -392,7 +395,7 @@ gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
}
else
{
- img_buffer = pixbuf->pixels;
+ img_buffer = (guint8 *) gdk_pixbuf_read_pixels (pixbuf);
length = rowstride * height;
}
diff --git a/gdk-pixbuf/io-ani-animation.c b/gdk-pixbuf/io-ani-animation.c
index cba58af64..0f0a68ee6 100644
--- a/gdk-pixbuf/io-ani-animation.c
+++ b/gdk-pixbuf/io-ani-animation.c
@@ -21,7 +21,6 @@
#include "config.h"
#include <errno.h>
-#include "gdk-pixbuf-private.h"
#include "io-ani-animation.h"
static void gdk_pixbuf_ani_anim_finalize (GObject *object);
diff --git a/gdk-pixbuf/io-ani-animation.h b/gdk-pixbuf/io-ani-animation.h
index 9e9b24085..788fb3e4a 100644
--- a/gdk-pixbuf/io-ani-animation.h
+++ b/gdk-pixbuf/io-ani-animation.h
@@ -22,7 +22,7 @@
#ifndef GDK_PIXBUF_ANI_ANIMATION_H
#define GDK_PIXBUF_ANI_ANIMATION_H
-#include "gdk-pixbuf-private.h"
+#include <glib/gi18n-lib.h>
#include "gdk-pixbuf-animation.h"
typedef struct _GdkPixbufAniAnim GdkPixbufAniAnim;
diff --git a/gdk-pixbuf/io-ani.c b/gdk-pixbuf/io-ani.c
index ee3fbe001..f08efa1c5 100644
--- a/gdk-pixbuf/io-ani.c
+++ b/gdk-pixbuf/io-ani.c
@@ -24,7 +24,6 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
-#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-loader.h"
#include "io-ani-animation.h"
diff --git a/gdk-pixbuf/io-bmp.c b/gdk-pixbuf/io-bmp.c
index 996822635..13ad6f2bc 100644
--- a/gdk-pixbuf/io-bmp.c
+++ b/gdk-pixbuf/io-bmp.c
@@ -28,7 +28,11 @@
#include <unistd.h>
#endif
#include <string.h>
-#include "gdk-pixbuf-private.h"
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
#define DUMPBIH 0
@@ -502,9 +506,11 @@ static gboolean DecodeHeader(unsigned char *BFH, unsigned char *BIH,
/* 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);
+ gint rowstride = gdk_pixbuf_get_rowstride (State->pixbuf);
+
+ memset (gdk_pixbuf_get_pixels (State->pixbuf), 0, rowstride * State->Header.height);
+ State->compr.p = gdk_pixbuf_get_pixels (State->pixbuf)
+ + rowstride * (State->Header.height- 1);
}
}
@@ -799,13 +805,14 @@ static void OneLine32(struct bmp_progressive_state *context)
int i;
guchar *pixels;
guchar *src;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
if (!context->Header.Negative)
- pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride * context->Lines);
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
src = context->buff;
@@ -860,16 +867,15 @@ static void OneLine24(struct bmp_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
Pixels[X * 3 + 0] = context->buff[X * 3 + 2];
Pixels[X * 3 + 1] = context->buff[X * 3 + 1];
@@ -884,13 +890,14 @@ static void OneLine16(struct bmp_progressive_state *context)
int i;
guchar *pixels;
guchar *src;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
if (!context->Header.Negative)
- pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride * context->Lines);
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
src = context->buff;
@@ -944,16 +951,15 @@ static void OneLine8(struct bmp_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
Pixels[X * 3 + 0] =
context->Colormap[context->buff[X]][2];
@@ -969,16 +975,15 @@ static void OneLine4(struct bmp_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
guchar Pix;
@@ -1010,16 +1015,15 @@ static void OneLine1(struct bmp_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gint rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
gint Bit;
@@ -1138,8 +1142,8 @@ DoCompressed(struct bmp_progressive_state *context, GError **error)
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))
+ context->compr.p = gdk_pixbuf_get_pixels (context->pixbuf)
+ + (gdk_pixbuf_get_rowstride (context->pixbuf) * (context->Header.height - context->compr.y - 1))
+ (4 * context->compr.x);
context->compr.phase = NEUTRAL;
break;
@@ -1164,8 +1168,8 @@ DoCompressed(struct bmp_progressive_state *context, GError **error)
break;
case DELTA_Y:
context->compr.y += c;
- context->compr.p = context->pixbuf->pixels
- + (context->pixbuf->rowstride * (context->Header.height - context->compr.y - 1))
+ context->compr.p = gdk_pixbuf_get_pixels (context->pixbuf)
+ + (gdk_pixbuf_get_rowstride (context->pixbuf) * (context->Header.height - context->compr.y - 1))
+ (4 * context->compr.x);
context->compr.phase = NEUTRAL;
break;
diff --git a/gdk-pixbuf/io-gif-animation.c b/gdk-pixbuf/io-gif-animation.c
index 6caed9dd4..171df7133 100644
--- a/gdk-pixbuf/io-gif-animation.c
+++ b/gdk-pixbuf/io-gif-animation.c
@@ -23,7 +23,6 @@
#include "config.h"
#include <errno.h>
#include "gdk-pixbuf-transform.h"
-#include "gdk-pixbuf-private.h"
#include "io-gif-animation.h"
static void gdk_pixbuf_gif_anim_finalize (GObject *object);
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 61821bdf9..7a4ce36a4 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -55,7 +55,8 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-io.h"
#include "io-gif-animation.h"
diff --git a/gdk-pixbuf/io-icns.c b/gdk-pixbuf/io-icns.c
index 41732b153..b832c761c 100644
--- a/gdk-pixbuf/io-icns.c
+++ b/gdk-pixbuf/io-icns.c
@@ -26,7 +26,11 @@
#include <string.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-loader.h"
G_MODULE_EXPORT void fill_vtable (GdkPixbufModule * module);
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index a86725751..8dca76ae4 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -44,7 +44,8 @@ Known bugs:
#endif
#include <string.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-io.h"
@@ -636,16 +637,15 @@ OneLine32 (struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
/* BGRA */
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
@@ -660,16 +660,15 @@ static void OneLine24(struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
Pixels[X * 4 + 0] = context->LineBuf[X * 3 + 2];
Pixels[X * 4 + 1] = context->LineBuf[X * 3 + 1];
@@ -686,15 +685,14 @@ OneLine16 (struct ico_progressive_state *context)
int i;
guchar *pixels;
guchar *src;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
if (context->Header.Negative == 0)
- pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
src = context->LineBuf;
@@ -724,16 +722,15 @@ static void OneLine8(struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
/* The joys of having a BGR byteorder */
Pixels[X * 4 + 0] =
@@ -750,16 +747,15 @@ static void OneLine4(struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
guchar Pix;
@@ -793,16 +789,15 @@ static void OneLine1(struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- context->Lines);
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * context->Lines);
while (X < context->Header.width) {
int Bit;
@@ -821,6 +816,7 @@ static void OneLineTransp(struct ico_progressive_state *context)
{
gint X;
guchar *Pixels;
+ gsize rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
/* Ignore the XOR mask for XP style 32-bpp icons with alpha */
if (context->Header.depth == 32)
@@ -828,13 +824,11 @@ static void OneLineTransp(struct ico_progressive_state *context)
X = 0;
if (context->Header.Negative == 0)
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (2*context->Header.height - context->Lines - 1));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (2*context->Header.height - context->Lines - 1));
else
- Pixels = (context->pixbuf->pixels +
- (gsize) context->pixbuf->rowstride *
- (context->Lines-context->Header.height));
+ Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
+ rowstride * (context->Lines-context->Header.height));
while (X < context->Header.width) {
int Bit;
diff --git a/gdk-pixbuf/io-jasper.c b/gdk-pixbuf/io-jasper.c
index b495f652b..f916cbf64 100644
--- a/gdk-pixbuf/io-jasper.c
+++ b/gdk-pixbuf/io-jasper.c
@@ -22,10 +22,11 @@
#include <string.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
-
#include <jasper/jasper.h>
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-io.h"
+
G_MODULE_EXPORT void fill_vtable (GdkPixbufModule * module);
G_MODULE_EXPORT void fill_info (GdkPixbufFormat * info);
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 87c705c6c..f22b5070d 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -33,8 +33,8 @@
#include <jpeglib.h>
#include <jerror.h>
#include <math.h>
-
-#include "gdk-pixbuf-private.h"
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-io.h"
#include "fallback-c89.c"
#ifndef HAVE_SIGSETJMP
@@ -44,6 +44,9 @@
#endif
+/* Helper macros to convert between density units */
+#define DPCM_TO_DPI(value) ((int) round ((value) * 2.54))
+
/* we are a "source manager" as far as libjpeg is concerned */
#define JPEG_PROG_BUF_SIZE 65536
@@ -677,14 +680,14 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error)
g_free (icc_profile_base64);
}
- dptr = pixbuf->pixels;
+ dptr = gdk_pixbuf_get_pixels (pixbuf);
/* decompress all the lines, a few at a time */
while (cinfo.output_scanline < cinfo.output_height) {
lptr = lines;
for (i = 0; i < cinfo.rec_outbuf_height; i++) {
*lptr++ = dptr;
- dptr += pixbuf->rowstride;
+ dptr += gdk_pixbuf_get_rowstride (pixbuf);
}
jpeg_read_scanlines (&cinfo, lines, cinfo.rec_outbuf_height);
@@ -915,7 +918,7 @@ gdk_pixbuf__jpeg_image_load_lines (JpegProgContext *context,
rowptr = context->dptr;
for (i=0; i < cinfo->rec_outbuf_height; i++) {
*lptr++ = rowptr;
- rowptr += context->pixbuf->rowstride;
+ rowptr += gdk_pixbuf_get_rowstride (context->pixbuf);
}
nlines = jpeg_read_scanlines (cinfo, lines,
@@ -943,7 +946,7 @@ gdk_pixbuf__jpeg_image_load_lines (JpegProgContext *context,
return FALSE;
}
- context->dptr += (gsize)nlines * context->pixbuf->rowstride;
+ context->dptr += (gsize)nlines * gdk_pixbuf_get_rowstride (context->pixbuf);
/* send updated signal */
if (context->updated_func)
@@ -1182,7 +1185,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
/* Use pixbuf buffer to store decompressed data */
- context->dptr = context->pixbuf->pixels;
+ context->dptr = gdk_pixbuf_get_pixels (context->pixbuf);
/* Notify the client that we are ready to go */
if (context->prepared_func)
@@ -1227,7 +1230,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
if (!context->in_output) {
if (jpeg_start_output (cinfo, cinfo->input_scan_number)) {
context->in_output = TRUE;
- context->dptr = context->pixbuf->pixels;
+ context->dptr = gdk_pixbuf_get_pixels (context->pixbuf);
}
else
break;
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index 6447ea373..dfe9e1e7d 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -27,9 +27,19 @@
#include <string.h>
#include <png.h>
#include <math.h>
-#include "gdk-pixbuf-private.h"
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
#include "fallback-c89.c"
+/* Helper macros to convert between density units */
+#define DPI_TO_DPM(value) ((int) round ((value) * 1000 / 25.4))
+#define DPM_TO_DPI(value) ((int) round ((value) * 25.4 / 1000))
+
+#define DEFAULT_FILL_COLOR 0x979899ff
+
static gboolean
setup_png_transformations(png_structp png_read_ptr, png_infop png_info_ptr,
GError **error,
@@ -247,6 +257,7 @@ static GdkPixbuf *
gdk_pixbuf__png_image_load (FILE *f, GError **error)
{
GdkPixbuf * volatile pixbuf = NULL;
+ gint rowstride;
png_structp png_ptr;
png_infop info_ptr;
png_textp text_ptr;
@@ -321,11 +332,13 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
return NULL;
}
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+
gdk_pixbuf_fill (pixbuf, DEFAULT_FILL_COLOR);
rows = g_new (png_bytep, h);
- for (i = 0, ptr = pixbuf->pixels; i < h; i++, ptr = (guchar *) ptr + pixbuf->rowstride)
+ for (i = 0, ptr = gdk_pixbuf_get_pixels (pixbuf); i < h; i++, ptr = (guchar *) ptr + rowstride)
rows[i] = ptr;
png_read_image (png_ptr, rows);
@@ -566,6 +579,8 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
return FALSE;
} else {
if (lc->first_row_seen_in_chunk >= 0 && lc->update_func) {
+ gint width = gdk_pixbuf_get_width (lc->pixbuf);
+
/* We saw at least one row */
gint pass_diff = lc->last_pass_seen_in_chunk - lc->first_pass_seen_in_chunk;
@@ -575,7 +590,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
/* start and end row were in the same pass */
(lc->update_func)(lc->pixbuf, 0,
lc->first_row_seen_in_chunk,
- lc->pixbuf->width,
+ width,
(lc->last_row_seen_in_chunk -
lc->first_row_seen_in_chunk) + 1,
lc->notify_user_data);
@@ -587,14 +602,14 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
/* first row to end */
(lc->update_func)(lc->pixbuf, 0,
lc->first_row_seen_in_chunk,
- lc->pixbuf->width,
+ width,
(lc->max_row_seen_in_chunk -
lc->first_row_seen_in_chunk) + 1,
lc->notify_user_data);
/* top to last row */
(lc->update_func)(lc->pixbuf,
0, 0,
- lc->pixbuf->width,
+ width,
lc->last_row_seen_in_chunk + 1,
lc->notify_user_data);
} else {
@@ -602,7 +617,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
whole image */
(lc->update_func)(lc->pixbuf,
0, 0,
- lc->pixbuf->width,
+ width,
lc->max_row_seen_in_chunk + 1,
lc->notify_user_data);
}
@@ -747,7 +762,7 @@ png_row_callback (png_structp png_read_ptr,
if (lc->fatal_error_occurred)
return;
- if (row_num >= lc->pixbuf->height) {
+ if (row_num >= gdk_pixbuf_get_height (lc->pixbuf)) {
lc->fatal_error_occurred = TRUE;
g_set_error_literal (lc->error,
GDK_PIXBUF_ERROR,
@@ -765,8 +780,8 @@ png_row_callback (png_structp png_read_ptr,
lc->last_row_seen_in_chunk = row_num;
lc->last_pass_seen_in_chunk = pass_num;
- rowstride = lc->pixbuf->rowstride;
- old_row = lc->pixbuf->pixels + (row_num * rowstride);
+ rowstride = gdk_pixbuf_get_rowstride (lc->pixbuf);
+ old_row = gdk_pixbuf_get_pixels (lc->pixbuf) + (row_num * rowstride);
png_progressive_combine_row(lc->png_read_ptr, old_row, new_row);
}
diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c
index 1332b09cc..d6f3e216c 100644
--- a/gdk-pixbuf/io-pnm.c
+++ b/gdk-pixbuf/io-pnm.c
@@ -25,7 +25,8 @@
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
-#include "gdk-pixbuf-private.h"
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-io.h"
#define PNM_BUF_SIZE 4096
@@ -781,8 +782,8 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error)
return NULL;
}
- context.rowstride = context.pixbuf->rowstride;
- context.pixels = context.pixbuf->pixels;
+ context.rowstride = gdk_pixbuf_get_rowstride (context.pixbuf);
+ context.pixels = gdk_pixbuf_get_pixels (context.pixbuf);
}
/* if we got here we're reading image data */
@@ -1010,8 +1011,8 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data,
return FALSE;
}
- context->pixels = context->pixbuf->pixels;
- context->rowstride = context->pixbuf->rowstride;
+ context->pixels = gdk_pixbuf_get_pixels (context->pixbuf);
+ context->rowstride = gdk_pixbuf_get_rowstride (context->pixbuf);
/* Notify the client that we are ready to go */
if (context->prepared_func)
diff --git a/gdk-pixbuf/io-qtif.c b/gdk-pixbuf/io-qtif.c
index c814c9dc2..79fd4ffa9 100644
--- a/gdk-pixbuf/io-qtif.c
+++ b/gdk-pixbuf/io-qtif.c
@@ -30,8 +30,8 @@
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
+#include <glib/gi18n-lib.h>
#include "gdk-pixbuf.h"
-#include "gdk-pixbuf-private.h"
/***
* Definitions
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index 13f8d8184..c007ce583 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -32,8 +32,11 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
-#include "gdk-pixbuf-private.h"
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-buffer-queue-private.h"
#undef DEBUG_TGA
@@ -190,13 +193,18 @@ static inline void
tga_write_pixel (TGAContext *ctx,
const TGAColor *color)
{
- guint x = (ctx->hdr->flags & TGA_ORIGIN_RIGHT) ? ctx->pbuf->width - ctx->pbuf_x - 1 : ctx->pbuf_x;
- guint y = (ctx->hdr->flags & TGA_ORIGIN_UPPER) ? ctx->pbuf_y : ctx->pbuf->height - ctx->pbuf_y - 1;
+ gint width = gdk_pixbuf_get_width (ctx->pbuf);
+ gint height = gdk_pixbuf_get_height (ctx->pbuf);
+ gint rowstride = gdk_pixbuf_get_rowstride (ctx->pbuf);
+ gint n_channels = gdk_pixbuf_get_n_channels (ctx->pbuf);
- memcpy (ctx->pbuf->pixels + y * ctx->pbuf->rowstride + x * ctx->pbuf->n_channels, color, ctx->pbuf->n_channels);
+ guint x = (ctx->hdr->flags & TGA_ORIGIN_RIGHT) ? width - ctx->pbuf_x - 1 : ctx->pbuf_x;
+ guint y = (ctx->hdr->flags & TGA_ORIGIN_UPPER) ? ctx->pbuf_y : height - ctx->pbuf_y - 1;
+
+ memcpy (gdk_pixbuf_get_pixels (ctx->pbuf) + y * rowstride + x * n_channels, color, n_channels);
ctx->pbuf_x++;
- if (ctx->pbuf_x >= ctx->pbuf->width)
+ if (ctx->pbuf_x >= width)
{
ctx->pbuf_x = 0;
ctx->pbuf_y++;
@@ -206,18 +214,26 @@ tga_write_pixel (TGAContext *ctx,
static gsize
tga_pixels_remaining (TGAContext *ctx)
{
- return ctx->pbuf->width * (ctx->pbuf->height - ctx->pbuf_y) - ctx->pbuf_x;
+ gint width = gdk_pixbuf_get_width (ctx->pbuf);
+ gint height = gdk_pixbuf_get_height (ctx->pbuf);
+
+ return width * (height - ctx->pbuf_y) - ctx->pbuf_x;
}
static gboolean
tga_all_pixels_written (TGAContext *ctx)
{
- return ctx->pbuf_y >= ctx->pbuf->height;
+ gint height = gdk_pixbuf_get_height (ctx->pbuf);
+
+ return ctx->pbuf_y >= height;
}
static void
tga_emit_update (TGAContext *ctx)
{
+ gint width = gdk_pixbuf_get_width (ctx->pbuf);
+ gint height = gdk_pixbuf_get_height (ctx->pbuf);
+
if (!ctx->ufunc)
return;
@@ -230,12 +246,12 @@ tga_emit_update (TGAContext *ctx)
if (ctx->hdr->flags & TGA_ORIGIN_UPPER)
(*ctx->ufunc) (ctx->pbuf,
0, ctx->pbuf_y_notified,
- ctx->pbuf->width, ctx->pbuf_y - ctx->pbuf_y_notified,
+ width, ctx->pbuf_y - ctx->pbuf_y_notified,
ctx->udata);
else
(*ctx->ufunc) (ctx->pbuf,
- 0, ctx->pbuf->height - ctx->pbuf_y,
- ctx->pbuf->width, ctx->pbuf_y - ctx->pbuf_y_notified,
+ 0, height - ctx->pbuf_y,
+ width, ctx->pbuf_y - ctx->pbuf_y_notified,
ctx->udata);
ctx->pbuf_y_notified = ctx->pbuf_y;
diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c
index 56de6ffed..8d9780583 100644
--- a/gdk-pixbuf/io-tiff.c
+++ b/gdk-pixbuf/io-tiff.c
@@ -35,7 +35,11 @@
#endif
#include <tiffio.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
#include "fallback-c89.c"
#ifdef G_OS_WIN32
@@ -47,6 +51,9 @@
#endif
+/* Helper macros to convert between density units */
+#define DPCM_TO_DPI(value) ((int) round ((value) * 2.54))
+
typedef struct _TiffContext TiffContext;
struct _TiffContext
{
@@ -287,20 +294,26 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error)
gdk_pixbuf_set_option (pixbuf, "multipage", "yes");
#if G_BYTE_ORDER == G_BIG_ENDIAN
- /* Turns out that the packing used by TIFFRGBAImage depends on
- * the host byte order...
- */
- while (pixels < pixbuf->pixels + bytes) {
- uint32 pixel = *(uint32 *)pixels;
- int r = TIFFGetR(pixel);
- int g = TIFFGetG(pixel);
- int b = TIFFGetB(pixel);
- int a = TIFFGetA(pixel);
- *pixels++ = r;
- *pixels++ = g;
- *pixels++ = b;
- *pixels++ = a;
- }
+ {
+ guchar *pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf);
+
+ pixels = pixbuf_pixels;
+
+ /* Turns out that the packing used by TIFFRGBAImage depends on
+ * the host byte order...
+ */
+ while (pixels < pixbuf_pixels + bytes) {
+ uint32 pixel = *(uint32 *)pixels;
+ int r = TIFFGetR(pixel);
+ int g = TIFFGetG(pixel);
+ int b = TIFFGetB(pixel);
+ int a = TIFFGetA(pixel);
+ *pixels++ = r;
+ *pixels++ = g;
+ *pixels++ = b;
+ *pixels++ = a;
+ }
+ }
#endif
if (context && context->update_func)
diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c
index d21ee1f6a..e6fa4c019 100644
--- a/gdk-pixbuf/io-xbm.c
+++ b/gdk-pixbuf/io-xbm.c
@@ -35,8 +35,10 @@
#endif
#include <stdio.h>
#include <errno.h>
-#include "gdk-pixbuf-private.h"
#include <glib/gstdio.h>
+#include <glib/gi18n-lib.h>
+
+#include "gdk-pixbuf-io.h"
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index a98b1f391..fedcc708d 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -30,8 +30,10 @@
#include <unistd.h> /* for unlink */
#endif
#include <errno.h>
-#include "gdk-pixbuf-private.h"
#include <glib/gstdio.h>
+#include <glib/gi18n-lib.h>
+#include "gdk-pixbuf-core.h"
+#include "gdk-pixbuf-io.h"
@@ -458,6 +460,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
XPMColor *colors, *color, *fallbackcolor;
guchar *pixtmp;
GdkPixbuf *pixbuf;
+ gint rowstride;
fallbackcolor = NULL;
@@ -588,10 +591,12 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
return NULL;
}
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+
wbytes = w * cpp;
for (ycnt = 0; ycnt < h; ycnt++) {
- pixtmp = pixbuf->pixels + ycnt * pixbuf->rowstride;
+ pixtmp = gdk_pixbuf_get_pixels (pixbuf) + ycnt * rowstride;
buffer = (*get_buf) (op_body, handle);
if ((!buffer) || (strlen (buffer) < wbytes))
@@ -744,7 +749,11 @@ gdk_pixbuf__xpm_image_stop_load (gpointer data,
NULL,
context->user_data);
if (context->update_func)
- (* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data);
+ (* context->update_func) (pixbuf,
+ 0, 0,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ context->user_data);
g_object_unref (pixbuf);
retval = TRUE;