somewhat safer use of the colormap

svn path=/trunk/; revision=26974
This commit is contained in:
Sven Neumann
2008-09-17 15:03:36 +00:00
parent 78c71c9d9d
commit db99239b76

View File

@ -18,6 +18,8 @@
#include "config.h" #include "config.h"
#include <string.h>
#include <libgimp/gimp.h> #include <libgimp/gimp.h>
#include <libgimp/gimpui.h> #include <libgimp/gimpui.h>
@ -171,7 +173,7 @@ print_cairo_surface_from_drawable (gint32 drawable_ID)
cairo_surface_t *surface; cairo_surface_t *surface;
const gint width = drawable->width; const gint width = drawable->width;
const gint height = drawable->height; const gint height = drawable->height;
guchar *cmap = NULL; guchar cmap[3 * 256] = { 0, };
guchar *pixels; guchar *pixels;
gint stride; gint stride;
guint count = 0; guint count = 0;
@ -180,8 +182,12 @@ print_cairo_surface_from_drawable (gint32 drawable_ID)
if (gimp_drawable_is_indexed (drawable_ID)) if (gimp_drawable_is_indexed (drawable_ID))
{ {
cmap = gimp_image_get_colormap (gimp_drawable_get_image (drawable_ID), guchar *colors;
NULL); gint num_colors;
colors = gimp_image_get_colormap (gimp_drawable_get_image (drawable_ID),
&num_colors);
memcpy (cmap, colors, 3 * num_colors);
} }
surface = cairo_image_surface_create (gimp_drawable_has_alpha (drawable_ID) ? surface = cairo_image_surface_create (gimp_drawable_has_alpha (drawable_ID) ?