gimp r26973 - in trunk: . libgimp plug-ins/print
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26973 - in trunk: . libgimp plug-ins/print
- Date: Wed, 17 Sep 2008 14:45:56 +0000 (UTC)
Author: neo
Date: Wed Sep 17 14:45:56 2008
New Revision: 26973
URL: http://svn.gnome.org/viewvc/gimp?rev=26973&view=rev
Log:
2008-09-17 Sven Neumann <sven gimp org>
* libgimp/gimpimage.c (gimp_image_get_colormap): allow to pass
NULL for "num_colors".
* plug-ins/print/print-draw-page.c: added missing conversion
routines for indexed images. Fixes bug #552609.
Modified:
trunk/ChangeLog
trunk/libgimp/gimpimage.c
trunk/plug-ins/print/print-draw-page.c
Modified: trunk/libgimp/gimpimage.c
==============================================================================
--- trunk/libgimp/gimpimage.c (original)
+++ trunk/libgimp/gimpimage.c Wed Sep 17 14:45:56 2008
@@ -63,7 +63,7 @@
/**
* gimp_image_get_colormap:
* @image_ID: The image.
- * @num_colors: Number of colors in the colormap array.
+ * @num_colors: Returns the number of colors in the colormap array.
*
* Returns the image's colormap
*
@@ -82,7 +82,8 @@
cmap = _gimp_image_get_colormap (image_ID, &num_bytes);
- *num_colors = num_bytes / 3;
+ if (num_colors)
+ *num_colors = num_bytes / 3;
return cmap;
}
Modified: trunk/plug-ins/print/print-draw-page.c
==============================================================================
--- trunk/plug-ins/print/print-draw-page.c (original)
+++ trunk/plug-ins/print/print-draw-page.c Wed Sep 17 14:45:56 2008
@@ -30,13 +30,44 @@
static cairo_surface_t * print_cairo_surface_from_drawable (gint32 drawable_ID);
static inline void
+convert_from_rgb (const guchar *src,
+ guchar *dest,
+ gint pixels)
+{
+ while (pixels--)
+ {
+ GIMP_CAIRO_RGB24_SET_PIXEL (dest,
+ src[0], src[1], src[2]);
+
+ src += 3;
+ dest += 4;
+ }
+}
+
+static inline void
+convert_from_rgba (const guchar *src,
+ guchar *dest,
+ gint pixels)
+{
+ while (pixels--)
+ {
+ GIMP_CAIRO_ARGB32_SET_PIXEL (dest,
+ src[0], src[1], src[2], src[3]);
+
+ src += 4;
+ dest += 4;
+ }
+}
+
+static inline void
convert_from_gray (const guchar *src,
guchar *dest,
gint pixels)
{
while (pixels--)
{
- GIMP_CAIRO_RGB24_SET_PIXEL (dest, src[0], src[0], src[0]);
+ GIMP_CAIRO_RGB24_SET_PIXEL (dest,
+ src[0], src[0], src[0]);
src += 1;
dest += 4;
@@ -50,7 +81,8 @@
{
while (pixels--)
{
- GIMP_CAIRO_ARGB32_SET_PIXEL (dest, src[0], src[0], src[0], src[1]);
+ GIMP_CAIRO_ARGB32_SET_PIXEL (dest,
+ src[0], src[0], src[0], src[1]);
src += 2;
dest += 4;
@@ -58,29 +90,37 @@
}
static inline void
-convert_from_rgb (const guchar *src,
- guchar *dest,
- gint pixels)
+convert_from_indexed (const guchar *src,
+ guchar *dest,
+ gint pixels,
+ const guchar *cmap)
{
while (pixels--)
{
- GIMP_CAIRO_RGB24_SET_PIXEL (dest, src[0], src[1], src[2]);
+ const gint i = 3 * src[0];
- src += 3;
+ GIMP_CAIRO_RGB24_SET_PIXEL (dest,
+ cmap[i], cmap[i + 1], cmap[i + 2]);
+
+ src += 1;
dest += 4;
}
}
static inline void
-convert_from_rgba (const guchar *src,
- guchar *dest,
- gint pixels)
+convert_from_indexeda (const guchar *src,
+ guchar *dest,
+ gint pixels,
+ const guchar *cmap)
{
while (pixels--)
{
- GIMP_CAIRO_ARGB32_SET_PIXEL (dest, src[0], src[1], src[2], src[3]);
+ const gint i = 3 * src[0];
- src += 4;
+ GIMP_CAIRO_ARGB32_SET_PIXEL (dest,
+ cmap[i], cmap[i + 1], cmap[i + 2], src[1]);
+
+ src += 2;
dest += 4;
}
}
@@ -125,17 +165,25 @@
static cairo_surface_t *
print_cairo_surface_from_drawable (gint32 drawable_ID)
{
- GimpDrawable *drawable = gimp_drawable_get (drawable_ID);
+ GimpDrawable *drawable = gimp_drawable_get (drawable_ID);
GimpPixelRgn region;
+ GimpImageType image_type = gimp_drawable_type (drawable_ID);
cairo_surface_t *surface;
- const gint width = drawable->width;
- const gint height = drawable->height;
+ const gint width = drawable->width;
+ const gint height = drawable->height;
+ guchar *cmap = NULL;
guchar *pixels;
gint stride;
- guint count = 0;
- guint done = 0;
+ guint count = 0;
+ guint done = 0;
gpointer pr;
+ if (gimp_drawable_is_indexed (drawable_ID))
+ {
+ cmap = gimp_image_get_colormap (gimp_drawable_get_image (drawable_ID),
+ NULL);
+ }
+
surface = cairo_image_surface_create (gimp_drawable_has_alpha (drawable_ID) ?
CAIRO_FORMAT_ARGB32 :
CAIRO_FORMAT_RGB24,
@@ -156,22 +204,30 @@
for (y = 0; y < region.h; y++)
{
- switch (region.bpp)
+ switch (image_type)
{
- case 1:
+ case GIMP_RGB_IMAGE:
+ convert_from_rgb (src, dest, region.w);
+ break;
+
+ case GIMP_RGBA_IMAGE:
+ convert_from_rgba (src, dest, region.w);
+ break;
+
+ case GIMP_GRAY_IMAGE:
convert_from_gray (src, dest, region.w);
break;
- case 2:
+ case GIMP_GRAYA_IMAGE:
convert_from_graya (src, dest, region.w);
break;
- case 3:
- convert_from_rgb (src, dest, region.w);
+ case GIMP_INDEXED_IMAGE:
+ convert_from_indexed (src, dest, region.w, cmap);
break;
- case 4:
- convert_from_rgba (src, dest, region.w);
+ case GIMP_INDEXEDA_IMAGE:
+ convert_from_indexeda (src, dest, region.w, cmap);
break;
}
@@ -185,6 +241,8 @@
gimp_progress_update ((gdouble) done / (width * height));
}
+ g_free (cmap);
+
gimp_drawable_detach (drawable);
return surface;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]