diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-04-11 21:18:40 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-04-11 21:18:40 +0000 |
commit | 693951085158842b584cfb7289e5ad75d7d6600a (patch) | |
tree | cd98c146d4acb69ddc8cb837ba04b2f6f4af386f /gdk-pixbuf/io-pnm.c | |
parent | e60568a1da1c38da1793e9eab1364d0c8ddb6fa9 (diff) | |
download | gtk+-693951085158842b584cfb7289e5ad75d7d6600a.tar.gz |
More fixes for #77807:
* io-tga.c (get_contiguous_pixbuf): Helper function to create
a pixbuf with a contiguous pixel array while being careful about
overflow.
* io-tga.c (fill_in_context, get_image_pseudocolor,
get_image_truecolor, get_image_grayscale): Use
get_contiguous_pixbuf instead of manually allocating image
storage.
* io-xpm.c (pixbuf_create_from_xpm):
* io-pnm.c (gdk_pixbuf__pnm_image_load):
* io-jpeg.c (gdk_pixbuf__jpeg_image_load): Use gdk_pixbuf_new
instead of manually allocating image storage.
Diffstat (limited to 'gdk-pixbuf/io-pnm.c')
-rw-r--r-- | gdk-pixbuf/io-pnm.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c index adf843f33c..797f937178 100644 --- a/gdk-pixbuf/io-pnm.c +++ b/gdk-pixbuf/io-pnm.c @@ -93,13 +93,6 @@ static gboolean gdk_pixbuf__pnm_image_load_increment (gpointer context, static void explode_bitmap_into_buf (PnmLoaderContext *context); static void explode_gray_into_buf (PnmLoaderContext *context); -/* Destroy notification function for the pixbuf */ -static void -free_buffer (guchar *pixels, gpointer data) -{ - g_free (pixels); -} - /* explode bitmap data into rgb components */ /* we need to know what the row so we can */ @@ -764,10 +757,10 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error) context.output_row = 0; context.output_col = 0; - context.rowstride = context.width * 3; - context.pixels = g_try_malloc (context.height * context.width * 3); + context.pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, + context.width, context.height); - if (!context.pixels) { + if (!context.pixbuf) { /* Failed to allocate memory */ g_set_error (error, GDK_PIXBUF_ERROR, @@ -775,6 +768,9 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error) _("Can't allocate memory for loading PNM image")); return NULL; } + + context.rowstride = context.pixbuf->rowstride; + context.pixels = context.pixbuf->pixels; } /* if we got here we're reading image data */ @@ -797,10 +793,7 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error) break; } - return gdk_pixbuf_new_from_data (context.pixels, GDK_COLORSPACE_RGB, FALSE, 8, - context.width, context.height, - context.width * 3, free_buffer, NULL); - + return context.pixbuf; } /* |