diff --git a/ChangeLog b/ChangeLog index 5ab0f02f5c..557b9ab621 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-22 Sven Neumann + + * plug-ins/print/print.c + * plug-ins/print/print-draw-page.c: added support for grayscale + images so we don't need to go through an extra export step. + 2008-02-22 Sven Neumann * plug-ins/print/print.c diff --git a/plug-ins/print/print-draw-page.c b/plug-ins/print/print-draw-page.c index 81d384ff1b..a0662d4261 100644 --- a/plug-ins/print/print-draw-page.c +++ b/plug-ins/print/print-draw-page.c @@ -29,12 +29,18 @@ 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); -static inline void convert_from_rgba (const guchar *src, - guchar *dest, - gint pixels); +static inline void convert_from_gray (const guchar *src, + guchar *dest, + gint pixels); +static inline void convert_from_graya (const guchar *src, + guchar *dest, + gint pixels); +static inline void convert_from_rgb (const guchar *src, + guchar *dest, + gint pixels); +static inline void convert_from_rgba (const guchar *src, + guchar *dest, + gint pixels); gboolean @@ -110,6 +116,14 @@ print_cairo_surface_from_drawable (gint32 drawable_ID) { switch (region.bpp) { + case 1: + convert_from_gray (src, dest, region.w); + break; + + case 2: + convert_from_graya (src, dest, region.w); + break; + case 3: convert_from_rgb (src, dest, region.w); break; @@ -134,6 +148,34 @@ print_cairo_surface_from_drawable (gint32 drawable_ID) return surface; } +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]); + + src += 1; + dest += 4; + } +} + +static inline void +convert_from_graya (const guchar *src, + guchar *dest, + gint pixels) +{ + while (pixels--) + { + GIMP_CAIRO_ARGB32_SET_PIXEL (dest, src[0], src[0], src[0], src[1]); + + src += 2; + dest += 4; + } +} + static inline void convert_from_rgb (const guchar *src, guchar *dest, diff --git a/plug-ins/print/print.c b/plug-ins/print/print.c index 2747f8515a..81c1c14285 100644 --- a/plug-ins/print/print.c +++ b/plug-ins/print/print.c @@ -194,6 +194,7 @@ print_image (gint32 image_ID, /* export the image */ export = gimp_export_image (&image_ID, &drawable_ID, NULL, GIMP_EXPORT_CAN_HANDLE_RGB | + GIMP_EXPORT_CAN_HANDLE_GRAY | GIMP_EXPORT_CAN_HANDLE_ALPHA); if (export == GIMP_EXPORT_CANCEL)