summaryrefslogtreecommitdiff
path: root/prnt/hpijs/ljjetready.h
blob: e5f59533b6b9da16844cf200c8cb103b802ceae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*****************************************************************************\
  LJJetReady.h : Interface for the LJJetReady class

  Copyright (c) 1996 - 2008, Hewlett-Packard Co.
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
  3. Neither the name of Hewlett-Packard nor the names of its
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\*****************************************************************************/


#ifndef APDK_LJJETREADY_H
#define APDK_LJJETREADY_H

#include <setjmp.h>

extern "C"
{
#include "jpeglib.h"
}

APDK_BEGIN_NAMESPACE
/*!
\internal
*/

enum COMPRESS_MODE  {	COMPRESS_MODE0 = 0,
						COMPRESS_MODE2 = 2, 
						COMPRESS_MODE9 = 9,
						COMPRESS_MODE_AUTO = 10,
						COMPRESS_MODE_JPEG = 11,
						COMPRESS_MODE_LJ =   12
					};

class LJJetReady : public Printer
{
public:
    LJJetReady (SystemServices* pSS,int numfonts=0, BOOL proto=FALSE);
    ~LJJetReady ();

    virtual Header* SelectHeader (PrintContext* pc);
    virtual DRIVER_ERROR VerifyPenInfo ();
    virtual DRIVER_ERROR ParsePenInfo (PEN_TYPE& ePen, BOOL QueryPrinter=TRUE);
    virtual DISPLAY_STATUS ParseError (BYTE status_reg);
	inline virtual BOOL SupportSeparateBlack() {return FALSE;}
	virtual DRIVER_ERROR Flush (int FlushSize)
	{
		return NO_ERROR;
	}

    virtual BOOL GetMargins (PAPER_SIZE ps, float *fMargins)
    {
        fMargins[0] = (float) 0.1667;
        fMargins[1] = (float) 0.1667;
        fMargins[2] = (float) 0.1667;
        fMargins[3] = (float) 0.1667;
        return TRUE;
    }

    virtual BOOL UseCMYK (unsigned int iPrintMode) { return FALSE;}
	virtual DRIVER_ERROR Encapsulate (const RASTERDATA* InputRaster, BOOL bLastPlane);

//  See comments in ljmono.h for an explanation.

    virtual BOOL HagakiFeedDuplexerPresent (BOOL bQueryPrinter)
    {
        return TRUE;
    }
	virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode)
    {
        return FALSE;
    }


    Compressor* CreateCompressor (unsigned int RasterSize);
	Compressor* GetCompressor() { return m_pCompressor; }
	BOOL	bFGColorSet;
    BOOL    bGrey_K;
    int     m_iYPos;
	bool    m_bStartPageNotSent;
	HeaderLJJetReady  *phLJJetReady;

protected:

#ifdef APDK_HP_UX
    virtual LJJetReady & operator = (Printer& rhs)
    {
        return *this;
    }
#endif

	virtual DATA_FORMAT GetDataFormat() { return RASTER_STRIP; }
    BOOL        m_bJobStarted;
    int         m_iYResolution;
    Compressor  *m_pCompressor;
    PrintContext    *thePrintContext;
#ifdef HAVE_LIBDL
    void    *m_hHPLibHandle;
#endif
    COMPRESS_MODE    m_eCompressMode;

}; // LJJetReady

class LJJetReadyNormalMode : public PrintMode
{
public:
    LJJetReadyNormalMode ();
};   // LJJetReadyNormalMode

class LJJetReadyBestColorMode : public PrintMode
{
public:
    LJJetReadyBestColorMode ();
};   // LJJetReadyBestColorMode

class LJJetReadyGrayMode : public PrintMode
{
public:
    LJJetReadyGrayMode ();
};   // LJJetReadyGrayMode

class LJJetReadyBestGrayMode : public PrintMode
{
public:
    LJJetReadyBestGrayMode ();
};   // LJJetReadyBestGrayMode

/*!
\internal
*/

const int JPEG_HEADER_SIZE = 600; //As recommended by JPEG Library Docs
const int JPEG_TRAILER_SIZE = 100; //As recommended by JPEG Library Docs

const int QTABLE_SIZE =  64;
struct QTABLEINFO {
    DWORD qtable0[QTABLE_SIZE];
    DWORD qtable1[QTABLE_SIZE];
    DWORD qtable2[QTABLE_SIZE];
    int   qFactor;
};

class ModeJPEG : public Compressor
{
	friend class LJJetReady;
	friend class HeaderLJJetReady;

public:
    ModeJPEG(SystemServices* pSys, Printer* pPrinter, unsigned int RasterSize, COMPRESS_MODE eCompressMode);
    virtual ~ModeJPEG();
    BOOL Process(RASTERDATA* input);
	BYTE* NextOutputRaster(COLORTYPE color);
	unsigned int GetOutputWidth(COLORTYPE  color);
	long  GetCoordinates() { return m_lPrinterRasterRow; }
    DRIVER_ERROR SendWhiteStrips (int iPageHeight, BOOL bGray);

protected:
    BOOL    Compress( HPLJBITMAP *pSrcBmap,
                      HPLJBITMAP *pTrgBitmap,
                      QTABLEINFO *pQTable,
					  BOOL bGrayscaleSet
                    );

    BYTE*  GetBuffer(void);
    void   SetBuffer(BYTE* pJPEGBuffer);
    DWORD  GetJPEGBufferSize(void) const;

    static BYTE*   fpJPEGBuffer;      // This is passed destination JPEG buffer
    static DWORD   fJPEGBufferPos;    // position of first empty Byte in return Buffer
                                      //   has been called
    JSAMPROW    fRow_array[1];        // JPEG processing routine expects an
                                      //   array of pointers. We always send
                                      //   1 row at a time.

    DWORD  fBufferSize;
    BYTE*  fpJPEGStart;
    
    //----------------------------------------------------------------
    // These are JPEG library "objects" used in the actual jpeg compression routines
    //----------------------------------------------------------------
    struct jpeg_compress_struct   cinfo;
    struct jpeg_decompress_struct dinfo;
    struct jpeg_error_mgr jerr;
    struct jpeg_destination_mgr dest;
    jmp_buf setjmp_buffer;      /* for return to caller */

    //----------------------------------------------------------------
    // IJG dest manager callback
    //----------------------------------------------------------------
    static void jpeg_flush_output_buffer_callback(JOCTET *outbuf, BYTE* buffer, DWORD size);

private:
    Printer*            thePrinter;

    HPLJBITMAP			m_SourceBitmap;
	HPLJBITMAP          m_DestBitmap;
	long                m_lCurrCDRasterRow;			// Current  raster index. in PrintNextBand
    long                m_lPrinterRasterRow;		// Current printer raster row.
    int                 m_iRasterWidth;             // Input image width
    COMPRESS_MODE       m_eCompressMode;
}; //ModeJPEG


#ifdef APDK_LJJETREADY
//! LJJetReadyProxy
/*!
******************************************************************************/
class LJJetReadyProxy : public PrinterProxy
{
public:
    LJJetReadyProxy() : PrinterProxy(
        "LJJetReady",                   // family name
        "hp color LaserJet 3500\0"
		"hp color LaserJet 3550\0"
        "hp color LaserJet 3600\0"
        "Hp Color LaserJet CP151\0"
#ifdef APDK_MLC_PRINTER
#endif
    ) {m_iPrinterType = eLJJetReady;}
    inline Printer* CreatePrinter(SystemServices* pSS) const { return new LJJetReady(pSS); }
	inline PRINTER_TYPE GetPrinterType() const { return eLJJetReady;}
	inline unsigned int GetModelBit() const { return 0x1;}
};
#endif

APDK_END_NAMESPACE

#endif //APDK_LJJETREADY_H