plug-ins/print/print.c added support for grayscale images so we don't need

2008-02-22  Sven Neumann  <sven@gimp.org>

	* 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.

svn path=/trunk/; revision=24947
This commit is contained in:
Sven Neumann
2008-02-22 10:13:25 +00:00
committed by Sven Neumann
parent 8519952152
commit 7e9a5f7fe8
3 changed files with 55 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2008-02-22 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* plug-ins/print/print.c

View File

@ -29,6 +29,12 @@
static cairo_surface_t * print_cairo_surface_from_drawable (gint32 drawable_ID);
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);
@ -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,

View File

@ -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)