gimp r24947 - in trunk: . plug-ins/print



Author: neo
Date: Fri Feb 22 10:13:25 2008
New Revision: 24947
URL: http://svn.gnome.org/viewvc/gimp?rev=24947&view=rev

Log:
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.


Modified:
   trunk/ChangeLog
   trunk/plug-ins/print/print-draw-page.c
   trunk/plug-ins/print/print.c

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	Fri Feb 22 10:13:25 2008
@@ -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 @@
         {
           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;
@@ -135,6 +149,34 @@
 }
 
 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,
                   gint          pixels)

Modified: trunk/plug-ins/print/print.c
==============================================================================
--- trunk/plug-ins/print/print.c	(original)
+++ trunk/plug-ins/print/print.c	Fri Feb 22 10:13:25 2008
@@ -194,6 +194,7 @@
   /* 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)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]