1 /*****************************************************************************\
2 LJMono.cpp : Implementation of LJMono 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"
36 #include "resources.h"
37 #include "ColorMaps.h"
38 #include "PrinterCommands.h"
40 LJMono::LJMono() : Encapsulator()
42 memset(&m_PM, 0, sizeof(m_PM));
43 strcpy(m_szLanguage, "PCL");
50 DRIVER_ERROR LJMono::addJobSettings()
52 cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
53 "@PJL SET PAGEPROTECT=AUTO\012@PJL SET RESOLUTION=%d\012@PJL SET DENSITY=5\012", m_pQA->horizontal_resolution);
54 if (m_pQA->print_quality == -1)
56 cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
57 "@PJL SET RET=OFF\012@PJL SET ECONOMODE=ON\012");
59 if (m_pJA->e_duplex_mode != DUPLEXMODE_NONE)
61 cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr,
62 "@PJL SET DUPLEX=ON\012@PJL SET BINDING=%s\012",
63 (m_pJA->e_duplex_mode == DUPLEXMODE_BOOK) ? "LONGEDGE" :
68 addToHeader("@PJL SET DUPLEX=OFF\012", 19);
70 cur_pcl_buffer_ptr += sprintf((char *) cur_pcl_buffer_ptr, "@PJL ENTER LANGUAGE=%s\012", m_szLanguage);
72 DRIVER_ERROR err = Cleanup();
76 DRIVER_ERROR LJMono::Configure(Pipeline **pipeline)
81 ColorMatcher *pColorMatcher;
83 int iRows[MAXCOLORPLANES];
84 unsigned int uiResBoost;
88 * I need a flag in the printmode structure to whether create a CMYGraymap
89 * and set the ulMap1 to it.
93 m_PM.ColorDepth[0] = 1;
94 m_PM.cmap.ulMap1 = ulMapDJ600_CCM_K;
95 m_PM.BaseResX = m_pQA->horizontal_resolution;
96 m_PM.BaseResY = m_pQA->vertical_resolution;
98 m_PM.BlackFEDTable = HTBinary_open;
99 m_PM.ColorFEDTable = HTBinary_open;
100 m_PM.MixedRes = false;
102 for (int i = 0; i < MAXCOLORPLANES; i++)
104 m_PM.ResolutionX[i] = m_pQA->horizontal_resolution;
105 m_PM.ResolutionY[i] = m_pQA->vertical_resolution;
106 iRows[i] = m_PM.ResolutionX[i] / m_PM.BaseResX;
108 uiResBoost = m_PM.BaseResX / m_PM.BaseResY;
112 width = m_pMA->printable_width;
113 // unsigned int SeedBufferSize = m_pMA->printable_width * 3;
115 pColorMatcher = new ColorMatcher(m_PM.cmap, m_PM.dyeCount, width);
116 head = new Pipeline(pColorMatcher);
117 m_pHalftoner = new Halftoner (&m_PM, width, iRows, uiResBoost, m_PM.eHT == MATRIX);
118 p = new Pipeline(m_pHalftoner);
120 pMode2 = new Mode2(width);
121 p = new Pipeline(pMode2);
123 pMode2->myplane = COLORTYPE_COLOR;
129 DRIVER_ERROR LJMono::StartPage(JobAttributes *pJA)
132 m_pMA = &pJA->media_attributes;
133 m_pQA = &pJA->quality_attributes;
138 DRIVER_ERROR LJMono::FormFeed()
142 err = m_pSystemServices->Send((const BYTE *) "\x0C", 1);
146 DRIVER_ERROR LJMono::EndJob()
148 DRIVER_ERROR err = NO_ERROR;
150 err = m_pSystemServices->Send((const BYTE *) "\x1B*rC", 4);
151 err = m_pSystemServices->Send(Reset, sizeof(Reset));
153 err = m_pSystemServices->Send(UEL, sizeof(UEL));
157 DRIVER_ERROR LJMono::Encapsulate(RASTERDATA *InputRaster, bool bLastPlane)
159 DRIVER_ERROR err = NO_ERROR;
162 BYTE c = m_pHalftoner->LastPlane() ? 'W' : 'V';
163 iLen = sprintf (tmpStr, "\x1b*b%u%c", InputRaster->rastersize[COLORTYPE_COLOR], c);
164 err = this->Send((const BYTE *) tmpStr, iLen);
165 if (err == NO_ERROR && InputRaster->rastersize[COLORTYPE_COLOR] > 0)
167 err = this->Send(InputRaster->rasterdata[COLORTYPE_COLOR],
168 InputRaster->rastersize[COLORTYPE_COLOR]);