[gdk-pixbuf: 3/24] io-*.c: Use gdk_pixbuf_get_pixels(); don't access the pixels field directly



commit 5dd78ae0f43666206848bd7223689b9547056933
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon May 14 17:00:14 2018 -0500

    io-*.c: Use gdk_pixbuf_get_pixels(); don't access the pixels field directly

 gdk-pixbuf/io-bmp.c  | 32 ++++++++++++++++----------------
 gdk-pixbuf/io-ico.c  | 28 ++++++++++++++--------------
 gdk-pixbuf/io-jpeg.c |  6 +++---
 gdk-pixbuf/io-png.c  |  4 ++--
 gdk-pixbuf/io-pnm.c  |  4 ++--
 gdk-pixbuf/io-tga.c  |  2 +-
 gdk-pixbuf/io-xpm.c  |  2 +-
 7 files changed, 39 insertions(+), 39 deletions(-)
---
diff --git a/gdk-pixbuf/io-bmp.c b/gdk-pixbuf/io-bmp.c
index 996822635..1d0c06f5b 100644
--- a/gdk-pixbuf/io-bmp.c
+++ b/gdk-pixbuf/io-bmp.c
@@ -502,8 +502,8 @@ 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 
+                       memset (gdk_pixbuf_get_pixels (State->pixbuf), 0, State->pixbuf->rowstride * 
State->Header.height);
+                       State->compr.p = gdk_pixbuf_get_pixels (State->pixbuf) 
                                + State->pixbuf->rowstride * (State->Header.height- 1);
                }
        }
@@ -801,10 +801,10 @@ static void OneLine32(struct bmp_progressive_state *context)
        guchar *src;
 
        if (!context->Header.Negative)
-               pixels = (context->pixbuf->pixels +
+               pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
        else
-               pixels = (context->pixbuf->pixels +
+               pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride * context->Lines);
 
        src = context->buff;
@@ -863,11 +863,11 @@ static void OneLine24(struct bmp_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -886,10 +886,10 @@ static void OneLine16(struct bmp_progressive_state *context)
        guchar *src;
 
        if (!context->Header.Negative)
-               pixels = (context->pixbuf->pixels +
+               pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride * (context->Header.height - context->Lines - 1));
        else
-               pixels = (context->pixbuf->pixels +
+               pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride * context->Lines);
 
        src = context->buff;
@@ -947,11 +947,11 @@ static void OneLine8(struct bmp_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -972,11 +972,11 @@ static void OneLine4(struct bmp_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          context->Lines);
 
@@ -1013,11 +1013,11 @@ static void OneLine1(struct bmp_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -1138,7 +1138,7 @@ 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->compr.p = gdk_pixbuf_get_pixels (context->pixbuf) 
                                                + (context->pixbuf->rowstride * (context->Header.height - 
context->compr.y - 1))
                                                + (4 * context->compr.x);
                                        context->compr.phase = NEUTRAL;
@@ -1164,7 +1164,7 @@ DoCompressed(struct bmp_progressive_state *context, GError **error)
                            break;
                    case DELTA_Y:
                            context->compr.y += c;
-                           context->compr.p = context->pixbuf->pixels 
+                           context->compr.p = gdk_pixbuf_get_pixels (context->pixbuf) 
                                    + (context->pixbuf->rowstride * (context->Header.height - 
context->compr.y - 1))
                                    + (4 * context->compr.x);
                            context->compr.phase = NEUTRAL;
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index a86725751..df86f7bab 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -639,11 +639,11 @@ OneLine32 (struct ico_progressive_state *context)
 
         X = 0;
         if (context->Header.Negative == 0)
-                Pixels = (context->pixbuf->pixels +
+                Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                           (context->Header.height - context->Lines - 1));
         else
-                Pixels = (context->pixbuf->pixels +
+                Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                           context->Lines);
         while (X < context->Header.width) {
@@ -663,11 +663,11 @@ static void OneLine24(struct ico_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -688,11 +688,11 @@ OneLine16 (struct ico_progressive_state *context)
         guchar *src;
 
         if (context->Header.Negative == 0)
-                pixels = (context->pixbuf->pixels +
+                pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                           (context->Header.height - context->Lines - 1));
         else
-                pixels = (context->pixbuf->pixels +
+                pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                           context->Lines);
 
@@ -727,11 +727,11 @@ static void OneLine8(struct ico_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -753,11 +753,11 @@ static void OneLine4(struct ico_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          context->Lines);
        
@@ -796,11 +796,11 @@ static void OneLine1(struct ico_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          context->Lines);
        while (X < context->Header.width) {
@@ -828,11 +828,11 @@ static void OneLineTransp(struct ico_progressive_state *context)
 
        X = 0;
        if (context->Header.Negative == 0)
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (2*context->Header.height - context->Lines - 1));
        else
-               Pixels = (context->pixbuf->pixels +
+               Pixels = (gdk_pixbuf_get_pixels (context->pixbuf) +
                          (gsize) context->pixbuf->rowstride *
                          (context->Lines-context->Header.height));
        while (X < context->Header.width) {
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 87c705c6c..8b94dbc0a 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -677,7 +677,7 @@ 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) {
@@ -1182,7 +1182,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 +1227,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..b039af678 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -325,7 +325,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
 
        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 + 
pixbuf->rowstride)
                rows[i] = ptr;
 
        png_read_image (png_ptr, rows);
@@ -766,7 +766,7 @@ png_row_callback   (png_structp png_read_ptr,
         lc->last_pass_seen_in_chunk = pass_num;
 
         rowstride = lc->pixbuf->rowstride;
-        old_row = lc->pixbuf->pixels + (row_num * rowstride);
+        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..149988922 100644
--- a/gdk-pixbuf/io-pnm.c
+++ b/gdk-pixbuf/io-pnm.c
@@ -782,7 +782,7 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error)
                        }
 
                        context.rowstride = context.pixbuf->rowstride;
-                       context.pixels = context.pixbuf->pixels;
+                       context.pixels = gdk_pixbuf_get_pixels (context.pixbuf);
                }
                
                /* if we got here we're reading image data */
@@ -1010,7 +1010,7 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data,
                                return FALSE;
                        }
                        
-                       context->pixels = context->pixbuf->pixels;
+                       context->pixels = gdk_pixbuf_get_pixels (context->pixbuf);
                        context->rowstride = context->pixbuf->rowstride;
                        
                        /* Notify the client that we are ready to go */
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index 13f8d8184..5f71c22c4 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -193,7 +193,7 @@ tga_write_pixel (TGAContext     *ctx,
   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;
 
-  memcpy (ctx->pbuf->pixels + y * ctx->pbuf->rowstride + x * ctx->pbuf->n_channels, color, 
ctx->pbuf->n_channels);
+  memcpy (gdk_pixbuf_get_pixels (ctx->pbuf) + y * ctx->pbuf->rowstride + x * ctx->pbuf->n_channels, color, 
ctx->pbuf->n_channels);
 
   ctx->pbuf_x++;
   if (ctx->pbuf_x >= ctx->pbuf->width)
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index a98b1f391..c3c71e92f 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -591,7 +591,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
        wbytes = w * cpp;
 
        for (ycnt = 0; ycnt < h; ycnt++) {
-               pixtmp = pixbuf->pixels + ycnt * pixbuf->rowstride;
+               pixtmp = gdk_pixbuf_get_pixels (pixbuf) + ycnt * pixbuf->rowstride;
 
                buffer = (*get_buf) (op_body, handle);
                if ((!buffer) || (strlen (buffer) < wbytes))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]