diff options
author | Federico Mena Quintero <federico@gnome.org> | 2018-05-14 18:00:30 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2018-06-01 18:47:33 -0500 |
commit | 158b2a3f07bcc2c57950dedda3bfc2d129a38a82 (patch) | |
tree | 98199ef15d05e6cb509336481ed0857558e11c2d /gdk-pixbuf/io-tga.c | |
parent | a90b4e5bf43d62f9ea5ebd913b06716e52d4654f (diff) | |
download | gdk-pixbuf-158b2a3f07bcc2c57950dedda3bfc2d129a38a82.tar.gz |
io-tga.c: Don't use gdk-pixbuf-private.h
Diffstat (limited to 'gdk-pixbuf/io-tga.c')
-rw-r--r-- | gdk-pixbuf/io-tga.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c index 5f71c22c4..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 (gdk_pixbuf_get_pixels (ctx->pbuf) + 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; |