Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / ljjetready.h
1 /*****************************************************************************\
2   LJJetReady.h : Interface for the LJJetReady class
3
4   Copyright (c) 1996 - 2008, Hewlett-Packard Co.
5   All rights reserved.
6
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions
9   are met:
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.
18
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 \*****************************************************************************/
30
31
32 #ifndef APDK_LJJETREADY_H
33 #define APDK_LJJETREADY_H
34 \r
35 #ifdef APDK_LJJETREADY\r
36
37 #include <setjmp.h>
38
39 extern "C"
40 {
41 #include "jpeglib.h"
42 }
43
44 APDK_BEGIN_NAMESPACE
45 /*!
46 \internal
47 */
48
49 enum COMPRESS_MODE  {   COMPRESS_MODE0 = 0,
50                                                 COMPRESS_MODE2 = 2, 
51                                                 COMPRESS_MODE9 = 9,
52                                                 COMPRESS_MODE_AUTO = 10,
53                                                 COMPRESS_MODE_JPEG = 11,
54                                                 COMPRESS_MODE_LJ =   12,\r
55                         COMPRESS_MODE_GRAFIT = 16
56                                         };
57
58 class LJJetReady : public Printer
59 {
60 public:
61     LJJetReady (SystemServices* pSS,int numfonts=0, BOOL proto=FALSE);
62     ~LJJetReady ();
63
64     virtual Header* SelectHeader (PrintContext* pc);
65     virtual DRIVER_ERROR VerifyPenInfo ();
66     virtual DRIVER_ERROR ParsePenInfo (PEN_TYPE& ePen, BOOL QueryPrinter=TRUE);
67     virtual DISPLAY_STATUS ParseError (BYTE status_reg);
68         inline virtual BOOL SupportSeparateBlack() {return FALSE;}
69         virtual DRIVER_ERROR Flush (int FlushSize)
70         {
71                 return NO_ERROR;
72         }
73
74     virtual BOOL GetMargins (PAPER_SIZE ps, float *fMargins)
75     {
76         fMargins[0] = (float) 0.1667;
77         fMargins[1] = (float) 0.1667;
78         fMargins[2] = (float) 0.1667;
79         fMargins[3] = (float) 0.1667;
80         return TRUE;
81     }
82
83     virtual BOOL UseCMYK (unsigned int iPrintMode) { return FALSE;}
84         virtual DRIVER_ERROR Encapsulate (const RASTERDATA* InputRaster, BOOL bLastPlane);
85
86 //  See comments in ljmono.h for an explanation.
87
88     virtual BOOL HagakiFeedDuplexerPresent (BOOL bQueryPrinter)
89     {
90         return TRUE;
91     }
92         virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode)
93     {
94         return FALSE;
95     }
96
97
98     Compressor* CreateCompressor (unsigned int RasterSize);
99         Compressor* GetCompressor() { return m_pCompressor; }
100         BOOL    bFGColorSet;
101     BOOL    bGrey_K;
102     int     m_iYPos;
103         bool    m_bStartPageNotSent;
104         HeaderLJJetReady  *phLJJetReady;
105
106 protected:
107
108 #ifdef APDK_HP_UX
109     virtual LJJetReady & operator = (Printer& rhs)
110     {
111         return *this;
112     }
113 #endif
114
115         virtual DATA_FORMAT GetDataFormat() { return RASTER_STRIP; }
116     BOOL        m_bJobStarted;
117     int         m_iYResolution;
118     Compressor  *m_pCompressor;
119     PrintContext    *thePrintContext;
120 #ifdef HAVE_LIBDL
121     void    *m_hHPLibHandle;
122 #endif
123     COMPRESS_MODE    m_eCompressMode;
124
125 }; // LJJetReady
126
127 class LJJetReadyNormalMode : public PrintMode
128 {
129 public:
130     LJJetReadyNormalMode ();
131 };   // LJJetReadyNormalMode
132
133 class LJJetReadyBestColorMode : public PrintMode
134 {
135 public:
136     LJJetReadyBestColorMode ();
137 };   // LJJetReadyBestColorMode
138
139 class LJJetReadyGrayMode : public PrintMode
140 {
141 public:
142     LJJetReadyGrayMode ();
143 };   // LJJetReadyGrayMode
144
145 class LJJetReadyBestGrayMode : public PrintMode
146 {
147 public:
148     LJJetReadyBestGrayMode ();
149 };   // LJJetReadyBestGrayMode
150
151 /*!
152 \internal
153 */
154
155 const int JPEG_HEADER_SIZE = 600; //As recommended by JPEG Library Docs
156 const int JPEG_TRAILER_SIZE = 100; //As recommended by JPEG Library Docs
157
158 const int QTABLE_SIZE =  64;
159 struct QTABLEINFO {
160     DWORD qtable0[QTABLE_SIZE];
161     DWORD qtable1[QTABLE_SIZE];
162     DWORD qtable2[QTABLE_SIZE];
163     int   qFactor;
164 };
165
166 class ModeJPEG : public Compressor
167 {
168         friend class LJJetReady;
169         friend class HeaderLJJetReady;
170
171 public:
172     ModeJPEG(SystemServices* pSys, Printer* pPrinter, unsigned int RasterSize, COMPRESS_MODE eCompressMode);
173     virtual ~ModeJPEG();
174     BOOL Process(RASTERDATA* input);
175         BYTE* NextOutputRaster(COLORTYPE color);
176         unsigned int GetOutputWidth(COLORTYPE  color);
177         long  GetCoordinates() { return m_lPrinterRasterRow; }
178     DRIVER_ERROR SendWhiteStrips (int iPageHeight, BOOL bGray);
179
180 protected:
181     BOOL    Compress( HPLJBITMAP *pSrcBmap,
182                       HPLJBITMAP *pTrgBitmap,
183                       QTABLEINFO *pQTable,
184                                           BOOL bGrayscaleSet
185                     );
186
187     BYTE*  GetBuffer(void);
188     void   SetBuffer(BYTE* pJPEGBuffer);
189     DWORD  GetJPEGBufferSize(void) const;
190
191     static BYTE*   fpJPEGBuffer;      // This is passed destination JPEG buffer
192     static DWORD   fJPEGBufferPos;    // position of first empty Byte in return Buffer
193                                       //   has been called
194     JSAMPROW    fRow_array[1];        // JPEG processing routine expects an
195                                       //   array of pointers. We always send
196                                       //   1 row at a time.
197
198     DWORD  fBufferSize;
199     BYTE*  fpJPEGStart;
200     
201     //----------------------------------------------------------------
202     // These are JPEG library "objects" used in the actual jpeg compression routines
203     //----------------------------------------------------------------
204     struct jpeg_compress_struct   cinfo;
205     struct jpeg_decompress_struct dinfo;
206     struct jpeg_error_mgr jerr;
207     struct jpeg_destination_mgr dest;
208     jmp_buf setjmp_buffer;      /* for return to caller */
209
210     //----------------------------------------------------------------
211     // IJG dest manager callback
212     //----------------------------------------------------------------
213     static void jpeg_flush_output_buffer_callback(JOCTET *outbuf, BYTE* buffer, DWORD size);
214
215 private:
216     Printer*            thePrinter;
217
218     HPLJBITMAP                  m_SourceBitmap;
219         HPLJBITMAP          m_DestBitmap;
220         long                m_lCurrCDRasterRow;                 // Current  raster index. in PrintNextBand
221     long                m_lPrinterRasterRow;            // Current printer raster row.
222     int                 m_iRasterWidth;             // Input image width
223     COMPRESS_MODE       m_eCompressMode;
224 }; //ModeJPEG
225
226
227 #ifdef APDK_LJJETREADY
228 //! LJJetReadyProxy
229 /*!
230 ******************************************************************************/
231 class LJJetReadyProxy : public PrinterProxy
232 {
233 public:
234     LJJetReadyProxy() : PrinterProxy(
235         "LJJetReady",                   // family name
236         "hp color LaserJet 3500\0"
237                 "hp color LaserJet 3550\0"
238         "hp color LaserJet 3600\0"\r
239         "Hp Color LaserJet CP151\0"
240 #ifdef APDK_MLC_PRINTER
241 #endif
242     ) {m_iPrinterType = eLJJetReady;}
243     inline Printer* CreatePrinter(SystemServices* pSS) const { return new LJJetReady(pSS); }
244         inline PRINTER_TYPE GetPrinterType() const { return eLJJetReady;}
245         inline unsigned int GetModelBit() const { return 0x1;}
246 };
247 #endif
248
249 APDK_END_NAMESPACE
250 \r
251 #endif // APDK_LJJETREADY
252 #endif //APDK_LJJETREADY_H