00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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)