Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

src/main/color-raw.c

Go to the documentation of this file.
00001 /*
00002  * "$Id: print-color.c,v 1.106.2.31 2004/03/25 01:01:05 rlk Exp $"
00003  *
00004  *   Gimp-Print color management module - traditional Gimp-Print algorithm.
00005  *
00006  *   Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
00007  *      Robert Krawitz (rlk@alum.mit.edu)
00008  *
00009  *   This program is free software; you can redistribute it and/or modify it
00010  *   under the terms of the GNU General Public License as published by the Free
00011  *   Software Foundation; either version 2 of the License, or (at your option)
00012  *   any later version.
00013  *
00014  *   This program is distributed in the hope that it will be useful, but
00015  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00016  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00017  *   for more details.
00018  *
00019  *   You should have received a copy of the GNU General Public License
00020  *   along with this program; if not, write to the Free Software
00021  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023 
00024 /*
00025  * This file must include only standard C header files.  The core code must
00026  * compile on generic platforms that don't support glib, gimp, gtk, etc.
00027  */
00028 
00029 #ifdef HAVE_CONFIG_H
00030 #include <config.h>
00031 #endif
00032 #include <gimp-print/gimp-print.h>
00033 #include "gimp-print-internal.h"
00034 #include <gimp-print/gimp-print-intl-internal.h>
00035 #include <math.h>
00036 #ifdef HAVE_LIMITS_H
00037 #include <limits.h>
00038 #endif
00039 #include <string.h>
00040 #include "lut.h"
00041 
00042 #ifdef __GNUC__
00043 #define inline __inline__
00044 #endif
00045 
00046 #define RAW_COLOR_TO_COLOR_FUNC(T, bits)                                    \
00047 static unsigned                                                             \
00048 color_##bits##_to_color_raw(stp_const_vars_t vars, const unsigned char *in, \
00049                             unsigned short *out)                            \
00050 {                                                                           \
00051   int i;                                                                    \
00052   int j;                                                                    \
00053   int nz = 0;                                                               \
00054   const T *s_in = (const T *) in;                                           \
00055   lut_t *lut = (lut_t *)(stpi_get_component_data(vars, "Color"));           \
00056   unsigned mask = 0;                                                        \
00057   if (lut->invert_output)                                                   \
00058     mask = 0xffff;                                                          \
00059                                                                             \
00060   for (i = 0; i < lut->image_width; i++)                                    \
00061     {                                                                       \
00062       unsigned bit = 1;                                                     \
00063       for (j = 0; j < 3; j++, bit += bit)                                   \
00064         {                                                                   \
00065           out[j] = s_in[j] ^ mask;                                          \
00066           if (out[j])                                                       \
00067             nz |= bit;                                                      \
00068         }                                                                   \
00069       s_in += 3;                                                            \
00070       out += 3;                                                             \
00071     }                                                                       \
00072   return nz;                                                                \
00073 }
00074 
00075 RAW_COLOR_TO_COLOR_FUNC(unsigned char, 8)
00076 RAW_COLOR_TO_COLOR_FUNC(unsigned short, 16)
00077 GENERIC_COLOR_FUNC(color, color_raw)
00078 
00079 GRAY_TO_COLOR_FUNC(unsigned char, 8)
00080 GRAY_TO_COLOR_FUNC(unsigned short, 16)
00081 GENERIC_COLOR_FUNC(gray, color)
00082 
00083 #define GRAY_TO_COLOR_RAW_FUNC(T, bits)                                    \
00084 static unsigned                                                            \
00085 gray_##bits##_to_color_raw(stp_const_vars_t vars, const unsigned char *in, \
00086                            unsigned short *out)                            \
00087 {                                                                          \
00088   int i;                                                                   \
00089   int nz = 0;                                                              \
00090   const T *s_in = (const T *) in;                                          \
00091   lut_t *lut = (lut_t *)(stpi_get_component_data(vars, "Color"));          \
00092   unsigned mask = 0;                                                       \
00093   if (lut->invert_output)                                                  \
00094     mask = 0xffff;                                                         \
00095                                                                            \
00096   for (i = 0; i < lut->image_width; i++)                                   \
00097     {                                                                      \
00098       unsigned outval = s_in[0] ^ mask;                                    \
00099       out[0] = outval;                                                     \
00100       out[1] = outval;                                                     \
00101       out[2] = outval;                                                     \
00102       if (outval)                                                          \
00103         nz = 7;                                                            \
00104       s_in++;                                                              \
00105       out += 3;                                                            \
00106     }                                                                      \
00107   return nz;                                                               \
00108 }
00109 
00110 GRAY_TO_COLOR_RAW_FUNC(unsigned char, 8)
00111 GRAY_TO_COLOR_RAW_FUNC(unsigned short, 16)
00112 GENERIC_COLOR_FUNC(gray, color_raw)

Generated on Wed May 12 20:21:28 2004 for libgimpprint API Reference by doxygen1.2.17