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 \*****************************************************************************/
32 #ifndef APDK_COLORMATCH_H
33 #define APDK_COLORMATCH_H
37 #define OCT_MASK1 0x10
48 class ColorMatcher : public Processor
51 ColorMatcher(SystemServices* pSys,
52 ColorMap cm,unsigned int DyeCount,
53 unsigned int iInputWidth);
54 virtual ~ColorMatcher();
56 //virtual BOOL Process(BYTE* pbyInputRGBRaster=NULL, unsigned int size=0);
57 virtual BOOL Process(RASTERDATA* InputRaster=NULL);
60 DRIVER_ERROR constructor_error;
62 virtual void Restart(); // set up for new page or blanks
64 // items required by Processor
65 unsigned int GetOutputWidth(COLORTYPE rastercolor);
66 unsigned int GetMaxOutputWidth(COLORTYPE rastercolor);
67 BYTE* NextOutputRaster(COLORTYPE rastercolor);
69 unsigned int ColorPlaneCount;
70 unsigned int InputWidth; // # of pixels input
71 unsigned int StartPlane; // since planes are ordered KCMY, if no K, this is 1
72 unsigned int EndPlane; // usually Y, could be Mlight
73 unsigned int ResBoost;
75 DRIVER_ERROR MakeGrayMap(const uint32_t *colormap, uint32_t* graymap);
79 SystemServices* pSS; // needed for memory management
82 void ColorMatch( unsigned long width, const uint32_t *map, unsigned char *rgb,
83 unsigned char *kplane, unsigned char *cplane, unsigned char *mplane,
84 unsigned char *yplane );
85 // open/proprietary differ in this routine
86 virtual void Interpolate(const uint32_t *map,
87 unsigned char r,unsigned char g,unsigned char b,
88 unsigned char *blackout, unsigned char *cyanout,
89 unsigned char *magentaout, unsigned char *yellowout)=0;
92 void ColorMatch( unsigned long width, const unsigned char *map, unsigned char *rgb,
93 unsigned char *kplane, unsigned char *cplane, unsigned char *mplane,
94 unsigned char *yplane );
95 // open/proprietary differ in this routine
96 virtual void Interpolate(const unsigned char *map,
97 unsigned char r,unsigned char g,unsigned char b,
98 unsigned char *blackout, unsigned char *cyanout,
99 unsigned char *magentaout, unsigned char *yellowout)=0;
103 inline unsigned char GetYellowValue(uint32_t cmyk)
104 { return( ((unsigned char)((cmyk)>>24) & 0xFF) ); }
106 inline unsigned char GetMagentaValue(uint32_t cmyk)
107 { return( ((unsigned char)((cmyk)>>16) & 0xFF) ); }
109 inline unsigned char GetCyanValue(uint32_t cmyk)
110 { return( ((unsigned char)(((int)(cmyk))>>8) & 0xFF) ); }
112 inline unsigned char GetBlackValue(uint32_t cmyk)
113 { return( ((unsigned char)(cmyk) & 0xFF) ); }
115 HPBool Forward16PixelsNonWhite(HPBytePtr inputPtr)
117 // return ((*(HPUInt32Ptr)(inputPtr) != 0x0) || (*(((HPUInt32Ptr)(inputPtr)) + 1) != 0x0) ||
118 // (*(((HPUInt32Ptr)(inputPtr)) + 2) != 0x0) || (*(((HPUInt32Ptr)(inputPtr)) + 3) != 0x0));
119 for (int i=0; i < 16; i++)
121 if ((*inputPtr++)!=0)
128 HPBool Backward16PixelsNonWhite(HPBytePtr inputPtr)
130 // return ((*(HPUInt32Ptr)(inputPtr) != 0x0) || (*(((HPUInt32Ptr)(inputPtr)) - 1) != 0x0) ||
131 // (*(((HPUInt32Ptr)(inputPtr)) - 2) != 0x0) || (*(((HPUInt32Ptr)(inputPtr)) - 3) != 0x0));
132 for (int i=0; i < 16; i++)
134 if ((*inputPtr--)!=0)
142 unsigned char* Contone; // containing byte-per-pixel CMYK values
146 // void PixelMultiply(unsigned char* buffer, unsigned int width, unsigned int factor);
148 unsigned int PlaneCount(); // tells how many layers (colors,hifipe,multirow)
156 #endif //APDK_COLORMATCH_H