1 /*****************************************************************************\
2 colormatch.h : Interface for the ColorMatcher class
4 Copyright (c) 1996 - 2001, Hewlett-Packard Co.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 3. Neither the name of Hewlett-Packard nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \*****************************************************************************/
31 #ifndef COLORMATCHER_H
32 #define COLORMATCHER_H
36 #define OCT_MASK1 0x10
42 class ColorMatcher : public Processor
45 ColorMatcher(ColorMap cm, unsigned int DyeCount,
46 unsigned int iInputWidth);
47 virtual ~ColorMatcher();
49 bool Process(RASTERDATA* InputRaster=NULL);
51 DRIVER_ERROR constructor_error;
52 void Restart(); // set up for new page or blanks
54 // items required by Processor
55 unsigned int GetMaxOutputWidth();
56 bool NextOutputRaster(RASTERDATA &next_raster);
58 unsigned int ColorPlaneCount;
59 unsigned int InputWidth; // # of pixels input
60 unsigned int StartPlane; // since planes are ordered KCMY, if no K, this is 1
61 unsigned int EndPlane; // usually Y, could be Mlight
62 unsigned int ResBoost;
64 DRIVER_ERROR MakeGrayMap(const uint32_t *colormap, uint32_t* graymap);
68 void ColorMatch(unsigned long width, const uint32_t *map,
69 unsigned char *rgb, unsigned char *kplane,
70 unsigned char *cplane, unsigned char *mplane,
71 unsigned char *yplane);
72 void Interpolate(const uint32_t *map,
73 unsigned char r,unsigned char g,unsigned char b,
74 unsigned char *blackout, unsigned char *cyanout,
75 unsigned char *magentaout, unsigned char *yellowout);
77 void ColorMatch(unsigned long width, const unsigned char *map,
78 unsigned char *rgb, unsigned char *kplane,
79 unsigned char *cplane, unsigned char *mplane,
80 unsigned char *yplane);
81 void Interpolate(const unsigned char *map,
82 unsigned char r,unsigned char g,unsigned char b,
83 unsigned char *blackout, unsigned char *cyanout,
84 unsigned char *magentaout, unsigned char *yellowout);
87 inline unsigned char GetYellowValue(uint32_t cmyk)
88 { return( ((unsigned char)((cmyk)>>24) & 0xFF) ); }
90 inline unsigned char GetMagentaValue(uint32_t cmyk)
91 { return( ((unsigned char)((cmyk)>>16) & 0xFF) ); }
93 inline unsigned char GetCyanValue(uint32_t cmyk)
94 { return( ((unsigned char)(((int)(cmyk))>>8) & 0xFF) ); }
96 inline unsigned char GetBlackValue(uint32_t cmyk)
97 { return( ((unsigned char)(cmyk) & 0xFF) ); }
99 bool Forward16PixelsNonWhite(BYTE *inputPtr)
101 // return ((*(uint32_t *)(inputPtr) != 0x0) || (*(((uint32_t *)(inputPtr)) + 1) != 0x0) ||
102 // (*(((uint32_t *)(inputPtr)) + 2) != 0x0) || (*(((uint32_t *)(inputPtr)) + 3) != 0x0));
103 for (int i=0; i < 16; i++)
105 if ((*inputPtr++)!=0)
112 bool Backward16PixelsNonWhite(BYTE *inputPtr)
114 // return ((*(uint32_t *)(inputPtr) != 0x0) || (*(((uint32_t *)(inputPtr)) - 1) != 0x0) ||
115 // (*(((uint32_t *)(inputPtr)) - 2) != 0x0) || (*(((uint32_t *)(inputPtr)) - 3) != 0x0));
116 for (int i=0; i < 16; i++)
118 if ((*inputPtr--)!=0)
126 unsigned char* Contone; // containing byte-per-pixel CMYK values
130 // void PixelMultiply(unsigned char* buffer, unsigned int width, unsigned int factor);
132 unsigned int PlaneCount(); // tells how many layers (colors,hifipe,multirow)
138 #endif // COLORMATCHER_H