1
/*****************************************************************************\
2
LJColor.cpp : Implementation of LJColor class
4
Copyright (c) 1996 - 2009, 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
#include "CommonDefinitions.h"
33
#include "ColorMatcher.h"
34
#include "Halftoner.h"
37
#include "resources.h"
38
#include "ColorMaps.h"
39
#include "PrinterCommands.h"
41
LJColor::LJColor() : Encapsulator()
43
memset(&m_PM, 0, sizeof(m_PM));
44
strcpy(m_szLanguage, "PCL");
51
DRIVER_ERROR LJColor::addJobSettings()
53
cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
54
"@PJL SET PAGEPROTECT=AUTO\012@PJL SET RESOLUTION=%d\012@PJL SET DENSITY=5\012", m_pQA->horizontal_resolution);
55
if (m_pQA->print_quality == -1)
57
cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
58
"@PJL SET RET=OFF\012@PJL SET ECONOMODE=ON\012");
60
if (m_pJA->e_duplex_mode != DUPLEXMODE_NONE)
62
cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
63
"@PJL SET DUPLEX=ON\012@PJL SET BINDING=%s\012",
64
(m_pJA->e_duplex_mode == DUPLEXMODE_BOOK) ? "LONGEDGE" :
69
addToHeader("@PJL SET DUPLEX=OFF\012", 19);
71
cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr, "@PJL ENTER LANGUAGE=PCL\012");
73
DRIVER_ERROR err = Cleanup();
77
DRIVER_ERROR LJColor::Configure(Pipeline **pipeline)
83
width = m_pMA->printable_width;
86
* I need a flag in the printmode structure to whether create a CMYGraymap
87
* and set the ulMap1 to it.
91
// color_mode: 0 - color, 1 - grey_cmy, 2 - grey_k
93
m_PM.BaseResX = m_pQA->horizontal_resolution;
94
m_PM.BaseResY = m_pQA->vertical_resolution;
95
if (m_pJA->color_mode != 0)
97
ColorMatcher *pColorMatcher;
99
int iRows[MAXCOLORPLANES];
100
unsigned int uiResBoost;
102
m_PM.ColorDepth[0] = 1;
103
m_PM.cmap.ulMap1 = ulMapDJ600_CCM_K;
105
m_PM.BlackFEDTable = HTBinary_open;
106
m_PM.ColorFEDTable = HTBinary_open;
107
m_PM.MixedRes = false;
109
for (int i = 0; i < MAXCOLORPLANES; i++)
111
m_PM.ResolutionX[i] = m_pQA->horizontal_resolution;
112
m_PM.ResolutionY[i] = m_pQA->vertical_resolution;
113
iRows[i] = m_PM.ResolutionX[i] / m_PM.BaseResX;
115
uiResBoost = m_PM.BaseResX / m_PM.BaseResY;
119
pColorMatcher = new ColorMatcher(m_PM.cmap, m_PM.dyeCount, width);
120
head = new Pipeline(pColorMatcher);
121
m_pHalftoner = new Halftoner (&m_PM, width, iRows, uiResBoost, m_PM.eHT == MATRIX);
122
p = new Pipeline(m_pHalftoner);
124
pMode2 = new Mode2(width);
125
p = new Pipeline(pMode2);
127
pMode2->myplane = COLORTYPE_COLOR;
131
m_pMode3 = new Mode3(width * 3);
132
head = new Pipeline(m_pMode3);
133
m_pMode3->myplane = COLORTYPE_COLOR;
140
DRIVER_ERROR LJColor::StartPage(JobAttributes *pJA)
143
m_pMA = &pJA->media_attributes;
144
m_pQA = &pJA->quality_attributes;
149
DRIVER_ERROR LJColor::FormFeed()
153
err = m_pSystemServices->Send((const BYTE *) "\x0C", 1);
157
DRIVER_ERROR LJColor::EndJob()
159
DRIVER_ERROR err = NO_ERROR;
161
err = m_pSystemServices->Send((const BYTE *) "\x1B*rC", 4);
162
err = m_pSystemServices->Send(Reset, sizeof(Reset));
164
err = m_pSystemServices->Send(UEL, sizeof(UEL));
168
DRIVER_ERROR LJColor::Encapsulate(RASTERDATA *InputRaster, bool bLastPlane)
170
DRIVER_ERROR err = NO_ERROR;
174
iLen = sprintf (tmpStr, "\x1b*b%uW", InputRaster->rastersize[COLORTYPE_COLOR]);
175
err = this->Send((const BYTE *) tmpStr, iLen);
176
if (err == NO_ERROR && InputRaster->rastersize[COLORTYPE_COLOR] > 0)
178
err = this->Send(InputRaster->rasterdata[COLORTYPE_COLOR],
179
InputRaster->rastersize[COLORTYPE_COLOR]);
183
* Printers with low memory (64 MB or less) can run out of memory during decompressing
184
* the image data and will abort the job. To prevent this, restart raster command.
188
if (m_pJA->color_mode == 0 &&
189
m_pQA->horizontal_resolution >= 600 &&
192
// Reset seed our seed row
194
err = this->Send ((const BYTE *) "\033*rC\033*r1A\033*b3M", 14);
200
void LJColor::configureRasterData()
204
* Configure image data - ESC*v#W - # = 6 bytes
205
* 02 - RGB colorspace (00 - Device RGB)
207
* 08 - bits per index - ignored for direct pixel
208
* 08, 08, 08 - bits per primary each
211
addToHeader ((const BYTE *) "\033*v6W\00\03\010\010\010\010", 11);
213
// Continues tone dither
214
// Logical operation - 0
216
addToHeader ((const BYTE *) "\033*t18J", 6);
219
* Driver Configuration Command - ESC*#W - # = 3 bytes
220
* device id - 6 = color HP LaserJet Printer
221
* func index - 4 = Select Colormap
222
* argument - 2 = Vivid Graphics
225
addToHeader ((const BYTE *) "\033*o3W\06\04\06", 8);
228
* Program color palette entries
230
addToHeader ((const BYTE *) "\033*v255A\033*v255B\033*v255C\033*v0I", 26);
231
addToHeader ((const BYTE *) "\033*v255A\033*v0B\033*v0C\033*v6I", 22);
232
addToHeader ((const BYTE *) "\033*v0A\033*v255B\033*v0C\033*v5I", 22);
233
addToHeader ((const BYTE *) "\033*v0A\033*v0B\033*v255C\033*v3I", 22);
234
addToHeader ((const BYTE *) "\033*v255A\033*v255B\033*v0C\033*v4I", 24);
235
addToHeader ((const BYTE *) "\033*v255A\033*v0B\033*v255C\033*v2I", 24);
236
addToHeader ((const BYTE *) "\033*v0A\033*v255B\033*v255C\033*v1I", 24);
237
addToHeader ((const BYTE *) "\033*v0A\033*v0B\033*v0C\033*v7I", 20);
241
addToHeader ((const BYTE *) "\033*v7S", 5);