1 /*****************************************************************************\
2 Lidil.cpp : Implementation of Lidil 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"
32 #include "Encapsulator.h"
33 #include "LidilCompress.h"
35 #include "ColorMatcher.h"
36 #include "Halftoner.h"
37 #include "resources.h"
38 #include "ColorMaps.h"
39 #include "LidilPrintModes.h"
40 #include "PrinterCommands.h"
54 Lidil::Lidil() : Encapsulator()
59 m_iColorPenResolution = 300;
60 m_iBlackPenResolution = 1200;
61 m_iNumBlackNozzles = 400;
62 m_cPrintDirection = PRNDRN_LEFTTORIGHT;
70 m_bBidirectionalPrintingOn = true;
71 m_cKtoCVertAlign = 12;
73 m_pLidilCompress = NULL;
74 m_szCompressBuf = NULL;
76 val.int_value = 0x0102;
77 if (val.char_val[0] == 0x01)
78 m_bLittleEndian = false;
80 m_bLittleEndian = true;
86 delete m_pLidilCompress;
88 delete [] m_SwathData;
90 delete [] m_szCompressBuf;
93 DRIVER_ERROR Lidil::Configure(Pipeline **pipeline)
98 ColorMatcher *pColorMatcher;
99 int iRows[MAXCOLORPLANES];
100 unsigned int uiResBoost;
103 if (m_pPM->BaseResX != m_pQA->horizontal_resolution ||
104 m_pPM->BaseResY != m_pQA->vertical_resolution)
106 dbglog("Requested resolution not supported with requested printmode");
107 return UNSUPPORTED_PRINTMODE;
110 for (int i = 0; i < MAXCOLORPLANES; i++)
112 iRows[i] = m_pPM->ResolutionX[i] / m_pPM->BaseResX;
114 uiResBoost = m_pPM->BaseResX / m_pPM->BaseResY;
118 width = m_pMA->printable_width;
120 pColorMatcher = new ColorMatcher(m_pPM->cmap, m_pPM->dyeCount, width);
121 head = new Pipeline(pColorMatcher);
122 Halftoner *pHalftoner;
123 pHalftoner = new Halftoner (m_pPM, width, iRows, uiResBoost, m_pPM->eHT == MATRIX);
124 p = new Pipeline(pHalftoner);
131 DRIVER_ERROR Lidil::StartJob(SystemServices *pSystemServices, JobAttributes *pJA)
133 DRIVER_ERROR err = NO_ERROR;
134 m_pSystemServices = pSystemServices;
137 m_pMA = &pJA->media_attributes;
138 m_pQA = &pJA->quality_attributes;
140 if (!strcmp(m_pJA->printer_platform, "dj4100"))
143 m_iBytesPerSwing = 4;
144 m_iColorPenResolution = 600;
146 else if (!strcmp(m_pJA->printer_platform, "dj2600"))
149 m_iBytesPerSwing = 4;
150 m_iColorPenResolution = 600;
151 m_iBlackPenResolution = 600;
152 m_iNumBlackNozzles = 336;
154 if (m_pQA->print_quality == BEST_QUALITY && m_pQA->media_type == MEDIATYPE_PHOTO)
158 cur_pcl_buffer_size = PCL_BUFFER_SIZE;
159 pcl_buffer = new BYTE[cur_pcl_buffer_size + 2];
160 if (pcl_buffer == NULL)
162 return ALLOCMEM_ERROR;
164 memset(pcl_buffer, 0, cur_pcl_buffer_size);
165 cur_pcl_buffer_ptr = pcl_buffer;
167 if (!selectPrintMode())
169 dbglog("selectPrintMode failed, PrintMode name = %s", m_pQA->print_mode_name);
170 return UNSUPPORTED_PRINTMODE;
174 if (m_pPM->BaseResX != m_pQA->horizontal_resolution ||
175 m_pPM->BaseResY != m_pQA->vertical_resolution)
177 dbglog("Requested resolution not supported with requested printmode");
178 dbglog(" m_pPM->BaseResX = %d\n",m_pPM->BaseResX);
179 dbglog(" m_pPM->BaseResY = %d\n",m_pPM->BaseResY);
180 dbglog(" m_pQA->horizontal_resolution = %d\n",m_pQA->horizontal_resolution);
181 dbglog(" m_pQA->vertical_resolution = %d\n",m_pQA->vertical_resolution);
182 return UNSUPPORTED_PRINTMODE;
185 m_iVertPosn = (m_pMA->printable_start_y * DEVUNITS_XBOW) / m_pQA->vertical_resolution;
186 m_iLeftMargin = (m_pMA->printable_start_x * DEVUNITS_XBOW) / m_pQA->vertical_resolution;
187 if (m_pJA->print_borderless)
189 m_iVertPosn = (-m_pMA->vertical_overspray * DEVUNITS_XBOW) / (2 * m_pQA->vertical_resolution);
190 m_iLeftMargin = (-m_pMA->horizontal_overspray * DEVUNITS_XBOW) / (2 * m_pQA->horizontal_resolution);
193 err = allocateSwathBuffers();
196 dbglog("allocateSwathBuffers failed, err = %d", err);
200 addToHeader(LdlSync, sizeof(LdlSync));
201 cur_pcl_buffer_ptr[SYNC_CMD_OPT_SIZE] = FRAME_SYN;
202 err = m_pSystemServices->Send(pcl_buffer, SYNCSIZE);
203 cur_pcl_buffer_ptr = pcl_buffer;
204 addToHeader(LdlSyncComplete, sizeof(LdlSyncComplete));
205 addToHeader(LdlReset, sizeof(LdlReset));
206 UInt16 mem_needed = SIZEOF_LDLHDR + SIZEOF_LDL_JOB_CMDOPT + SIZEOF_LDLTERM;
207 if (m_lidil_version == 2)
211 fillLidilHeader(NULL, eLDLStartJob, mem_needed);
212 *cur_pcl_buffer_ptr++ = OPERATION_STJOB;
213 addInt32(m_pJA->job_id);
214 if (m_lidil_version == 2)
216 *cur_pcl_buffer_ptr++ = FRAME_SYN;
219 // m_pLidilCompress = new LidilCompress(m_bLittleEndian);
223 DRIVER_ERROR Lidil::EndJob()
225 DRIVER_ERROR err = NO_ERROR;
226 UInt16 mem_needed = SIZEOF_LDLHDR + SIZEOF_LDL_JOB_CMDOPT + SIZEOF_LDLTERM;
228 memset(pcl_buffer, 0, cur_pcl_buffer_size);
229 fillLidilHeader(NULL, eLDLEndJob, mem_needed);
230 *cur_pcl_buffer_ptr++ = OPERATION_ENDJOB;
231 addInt32(m_pJA->job_id);
232 *cur_pcl_buffer_ptr++ = FRAME_SYN;
233 addToHeader(LdlSync, sizeof(LdlSync));
234 cur_pcl_buffer_ptr += SYNC_CMD_OPT_SIZE;
235 *cur_pcl_buffer_ptr++ = FRAME_SYN;
236 cur_pcl_buffer_ptr = pcl_buffer + SYNCSIZE + mem_needed;
237 addToHeader(LdlSyncComplete, sizeof(LdlSyncComplete));
238 addToHeader(LdlReset, sizeof(LdlReset));
243 void Lidil::CancelJob()
245 UInt16 mem_needed = SIZEOF_LDLHDR + SIZEOF_LDL_JOB_CMDOPT
247 fillLidilHeader (NULL, eLDLControl, mem_needed);
248 addInt32 (m_pJA->job_id);
249 *cur_pcl_buffer_ptr++ = OPERATION_CANCJOB;
250 *cur_pcl_buffer_ptr++ = FRAME_SYN;
254 DRIVER_ERROR Lidil::StartPage(JobAttributes *pJA)
256 DRIVER_ERROR err = NO_ERROR;
258 m_pMA = &pJA->media_attributes;
259 m_pQA = &pJA->quality_attributes;
260 UInt32 mem_needed = SIZEOF_LDLHDR + SIZEOF_LDL_LDPAGE_CMDOPT
261 + SIZEOF_LDL_LDPAGE_OPTFLDS
264 memset (cur_pcl_buffer_ptr, 0, mem_needed);
266 fillLidilHeader (NULL, eLDLLoadPage, (UInt16) mem_needed);
267 *cur_pcl_buffer_ptr++ = m_pQA->media_type;;
268 *cur_pcl_buffer_ptr++ = MEDIASRC_MAINTRAY;
269 *cur_pcl_buffer_ptr++ = MEDIADEST_MAINBIN;
270 *cur_pcl_buffer_ptr++ = m_pQA->print_quality;
271 *cur_pcl_buffer_ptr++ = SPECLOAD_NONE;
273 addInt32((Int32) (m_pMA->physical_width * DEVUNITS_XBOW / m_pQA->horizontal_resolution));
274 addInt32((Int32) (m_pMA->physical_height * DEVUNITS_XBOW / m_pQA->vertical_resolution));
276 addInt32(MEDIALD_SPEED|NEED_TO_SERVICE_PERIOD|MINTIME_BTW_SWEEP);
278 // set up the option fields
279 *cur_pcl_buffer_ptr++ = 4; // MediaLoadSpeed;
280 *cur_pcl_buffer_ptr++ = 0; // NeedToServicePeriod;
281 addInt16 (200); // MinTimeBetweenSweeps
283 *cur_pcl_buffer_ptr++ = FRAME_SYN;
288 DRIVER_ERROR Lidil::SendCAPy(int iOffset)
290 DRIVER_ERROR err = NO_ERROR;
292 if (m_iRasterCount == 0)
294 m_iBlankRasters += iOffset;
298 int iCount = m_pPM->dyeCount * m_iBitDepth;
299 if (m_iBitDepth == 2 && m_pPM->dyeCount != 6)
302 RASTERDATA rasterdata;
303 memset(&rasterdata, 0, sizeof(rasterdata));
306 for (int i = 0; i < iCount; i++)
308 err = Encapsulate (&rasterdata, 0);
316 DRIVER_ERROR Lidil::FormFeed()
318 DRIVER_ERROR err = NO_ERROR;
320 int iCurNumRasters = m_iRasterCount;
321 if ((m_pQA->print_quality == DRAFT_QUALITY || m_pQA->vertical_resolution == 300) && m_iRasterCount)
323 else if (m_pQA->print_quality != DRAFT_QUALITY)
325 icount = 4 * m_iBitDepth;
326 iCurNumRasters = m_sSwathHeight * m_pPM->dyeCount;
330 n = m_sSwathHeight / (4 * m_iBitDepth);
332 n = n * (m_cPassNumber + 1) - m_iNextRaster;
333 for (i = 0; i < (int) m_pPM->dyeCount; i++)
335 for (j = 0; j < n; j++)
336 memset (m_SwathData[i][m_iNextRaster+j], 0, m_iImageWidth * m_iBitDepth);
339 n = m_sSwathHeight / (4 * m_iBitDepth);
343 m_iRasterCount = iCurNumRasters;
344 err = processSwath ();
348 if (m_iNextRaster >= m_sSwathHeight)
350 for (i = 0; i < (int) m_pPM->dyeCount; i++)
352 for (j = 0; j < n; j++)
353 memset (m_SwathData[i][m_iNextRaster+j], 0, m_iImageWidth * m_iBitDepth);
358 UInt16 mem_needed = SIZEOF_LDLHDR
359 + SIZEOF_LDL_EJPAGE_CMDOPT
360 + SIZEOF_LDL_EJPAGE_OPTFLDS
363 fillLidilHeader(NULL, eLDLEjectPage, mem_needed);
365 addInt32 (MEDIA_EJSPEED);
367 *cur_pcl_buffer_ptr++ = 15;
368 *cur_pcl_buffer_ptr++ = FRAME_SYN;
376 m_iVertPosn = (m_pMA->printable_start_y * DEVUNITS_XBOW) / m_pQA->vertical_resolution;
381 if (m_pJA->print_borderless)
383 m_iVertPosn = (int) (-m_pMA->vertical_overspray * DEVUNITS_XBOW) / (2 * m_pQA->vertical_resolution);
386 if (m_pQA->print_quality != DRAFT_QUALITY)
387 m_iRasterCount = (m_sSwathHeight - m_sSwathHeight / 4) * m_pPM->dyeCount;
389 if (m_pQA->print_quality == DRAFT_QUALITY && m_pQA->vertical_resolution != 300)
391 m_iRasterCount = (m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * m_pPM->dyeCount;
392 m_iVertPosn -= (((m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * 600 / m_pQA->vertical_resolution) * DEVUNITS_XBOW / 600);
396 if (m_pJA->print_borderless)
398 if (m_iVertPosn < -850) m_iVertPosn = -850;
402 if (m_iVertPosn < -600) m_iVertPosn = -600;
404 if (m_iBitDepth == 2)
407 for (i = 0; i < (int) m_pPM->dyeCount; i++)
409 for (int j = 0; j < m_sSwathHeight; j++)
411 memset (m_SwathData[i][j], 0, m_iImageWidth);
418 DRIVER_ERROR Lidil::Encapsulate(RASTERDATA *InputRaster, bool bLastPlane)
420 DRIVER_ERROR err = NO_ERROR;
422 if (m_iBitDepth == 2)
424 if (m_pPM->dyeCount != 6)
426 if (m_cPlaneNumber == 0)
433 if (m_pPM->dyeCount == 6)
435 iPlaneNum = m_cPlaneNumber % 2;
439 iPlaneNum = (m_cPlaneNumber + 1) % 2;
441 int iRowNum = (m_iRasterCount / 6) * 2 + iPlaneNum;
442 iRowNum = m_iNextRaster;
443 if (m_pPM->dyeCount == 6)
445 iCPlane = m_cPlaneNumber / 2;
449 iCPlane = (m_cPlaneNumber - 1) / 2;
453 if (!InputRaster->rasterdata[COLORTYPE_COLOR])
455 m_bPrevRowWasBlank = true;
456 memset (m_SwathData[iCPlane][iRowNum], 0, m_iImageWidth * 2);
460 m_bPrevRowWasBlank = false;
461 memcpy (m_SwathData[iCPlane][iRowNum], InputRaster->rasterdata[COLORTYPE_COLOR], InputRaster->rastersize[COLORTYPE_COLOR]);
464 if (m_pPM->dyeCount == 6)
466 m_cPlaneNumber = (m_cPlaneNumber + 1) % 12;
470 m_cPlaneNumber = (m_cPlaneNumber + 1) % 8;
475 if (InputRaster->rasterdata[COLORTYPE_COLOR] || !m_bPrevRowWasBlank)
477 applyShingleMask(iCPlane, InputRaster->rasterdata[COLORTYPE_COLOR]);
481 memset (m_SwathData[iCPlane][m_iNextRaster+1], 0, m_iImageWidth * 2);
484 if (m_pPM->dyeCount == 6)
486 m_cPlaneNumber = m_cPlaneNumber % 12;
490 m_cPlaneNumber = m_cPlaneNumber % 7;
496 if (InputRaster->rasterdata[COLORTYPE_COLOR] == NULL)
497 memset (m_SwathData[m_iNextColor][m_iNextRaster], 0, m_iImageWidth);
499 memcpy (m_SwathData[m_iNextColor][m_iNextRaster], InputRaster->rasterdata[COLORTYPE_COLOR], m_iImageWidth);
502 if (m_iBitDepth == 1 || (m_iBitDepth == 2 && iPlaneNum == 1))
504 if (m_iNextColor == (int) m_pPM->dyeCount)
507 if (m_iBitDepth == 2)
512 if (m_iRasterCount < (int) (m_sSwathHeight * m_pPM->dyeCount))
515 err = processSwath ();
517 if (m_iNextRaster >= m_sSwathHeight)
524 void Lidil::fillLidilHeader(void *pLidilHdr, int Command, UInt16 CmdLen, UInt16 DataLen)
526 memset(cur_pcl_buffer_ptr, 0, SIZEOF_LDLHDR);
527 *cur_pcl_buffer_ptr++ = FRAME_SYN;
529 cur_pcl_buffer_ptr += 2;
530 *cur_pcl_buffer_ptr++ = (BYTE) Command;
531 addInt16(m_sRefCount++);
535 void Lidil::addInt32(Int32 iVal)
538 val.int_value = iVal;
541 for (int i = 3; i > -1; i--)
542 *cur_pcl_buffer_ptr++ = val.char_val[i];
546 memcpy(cur_pcl_buffer_ptr, val.char_val, 4);
547 cur_pcl_buffer_ptr += 4;
551 void Lidil::addInt16(Int16 iVal)
554 val.int_value = iVal;
557 *cur_pcl_buffer_ptr++ = val.char_val[1];
558 *cur_pcl_buffer_ptr++ = val.char_val[0];
562 memcpy(cur_pcl_buffer_ptr, val.char_val, 2);
563 cur_pcl_buffer_ptr += 2;
568 bool Lidil::selectPrintMode(int index)
570 PrintMode *p = lidil_print_modes_table[index].print_modes;
573 if (!strcmp(m_pJA->printer_platform, "dj4100") || (!strcmp(m_pJA->printer_platform, "dj2600")))
575 //Encapsulator for Viper Trim class products is not written properly, hence mapping the Index to
577 iPMIndex = PQ_Cartridge_Map_ViperTrim[m_pJA->integer_values[2]][m_pJA->integer_values[1]];
581 iPMIndex = PQ_Cartridge_Map[m_pJA->integer_values[2]][m_pJA->integer_values[1]];
582 //m_pJA->integer_values[1] is basically cupsInteger1 value given in PPD.
583 //m_pJA->integer_values[2] is basically cupsInteger2 value given in PPD.
586 dbglog("CupeInteger1 = [%d]\n",m_pJA->integer_values[1]);
587 dbglog("CupeInteger2 = [%d]\n",m_pJA->integer_values[2]);
588 dbglog("PrintMode Index = [%d]\n",iPMIndex);
592 dbglog("Unsupported Cartridge and Print Quality combination..\n");
596 for (int i = 0; i < lidil_print_modes_table[index].count; i++, p++)
600 dbglog("Print Mode = [%s]\n",p->name);
609 bool Lidil::selectPrintMode(int index)
611 PrintMode *p = lidil_print_modes_table[index].print_modes;
612 for (int i = 0; i < lidil_print_modes_table[index].count; i++, p++)
614 if (!strcmp(m_pJA->quality_attributes.print_mode_name, p->name))
624 bool Lidil::selectPrintMode()
626 if (m_pJA->printer_platform[0] == 0)
628 dbglog("printer_platform is undefined");
631 for (unsigned int i = 0; i < sizeof(lidil_print_modes_table) / sizeof(lidil_print_modes_table[0]); i++)
633 if (!strcmp(m_pJA->printer_platform, lidil_print_modes_table[i].printer_platform_name))
635 return selectPrintMode(i);
638 dbglog("Unsupported printer_platform: %s", m_pJA->printer_platform);
642 DRIVER_ERROR Lidil::loadSweepData (BYTE *imagedata, int imagesize)
644 UInt16 mem_needed = SIZEOF_LDLHDR + SIZEOF_LDL_LDSWPDATA_CMDOPT
646 cur_pcl_buffer_ptr = pcl_buffer;
647 memset (pcl_buffer, 0, mem_needed);
648 if (mem_needed < LDLPACKET_MINSIZE)
650 memset(pcl_buffer + mem_needed-1, 0xFF, LDLPACKET_MINSIZE - mem_needed);
651 mem_needed = LDLPACKET_MINSIZE;
654 BYTE *compressed_dataptr = imagedata;
655 UInt16 compressed_size = imagesize;
657 if (m_pLidilCompress)
659 m_pLidilCompress->Init ((UInt16 *) (imagedata+16), imagesize);
660 m_pLidilCompress->CompressData ();
661 m_pLidilCompress->GetFrameInfo (&compressed_dataptr, &compressed_size);
664 fillLidilHeader (NULL, eLDLLoadSweepData, mem_needed, compressed_size);
665 addInt16 (imagesize);
666 pcl_buffer[15] = FRAME_SYN;
668 memcpy (compressed_dataptr, pcl_buffer, 16);
669 cur_pcl_buffer_ptr = pcl_buffer;
670 return (sendBuffer ((const BYTE *) compressed_dataptr, compressed_size+16));
673 DRIVER_ERROR Lidil::printSweep (UInt32 SweepSize,
677 Int32 VerticalPosition,
685 // determine how many colors will be generated
686 UInt16 colorcount = 0;
687 UInt32 uiAffectedColors = 0;
688 if (ColorPresent == true) colorcount += 3;
689 if (BlackPresent == true) colorcount++;
690 if (PhotoPresent == true)
692 if (ColorPresent == false)
699 if (m_lidil_version == 1)
701 mem_needed = SIZEOF_LDLHDR
702 + SIZEOF_LDL_PRTSWP_CMDOPT
703 + SIZEOF_LDL_PRTSWP_OPTFLDS
704 + SIZEOF_LDL_PRTSWP_COLROPT * colorcount
708 mem_needed += SIZEOF_LDL_COLROPT_ACTIVECOLR;
712 mem_needed = SIZEOF_LDLHDR
713 + SIZEOF_LDL_PRTSWP_CMDOPT + 7
714 + SIZEOF_LDL_PRTSWP_OPTFLDS
715 + SIZEOF_LDL_PRTSWP_COLROPT + 4
719 memset (pcl_buffer, 0, mem_needed);
720 cur_pcl_buffer_ptr = pcl_buffer;
722 fillLidilHeader (NULL, eLDLPrintSweep, mem_needed);
723 if (m_lidil_version == 2)
725 *cur_pcl_buffer_ptr++ = 1; // Version number
727 addInt32 (SweepSize);
728 addInt32 (VerticalPosition);
729 addInt32 (m_iLeftMargin);
730 if (m_lidil_version == 1)
732 // LIDIL First Version
733 *cur_pcl_buffer_ptr++ = SWINGFMT_UNCOMPRSS;
737 // LIDIL Second Version
738 *cur_pcl_buffer_ptr++ = 1;
740 *cur_pcl_buffer_ptr++ = PrintDirection;
741 if (m_lidil_version == 2)
743 addInt32 (0); // Shingle mask
745 addInt32 (IPS_CARRSPEED|IPS_INIPRNSPEED|ACCURATEPOSN_NEEDED);
746 // Carriage Speed - 25 for plain, 12 for photo
747 if (m_pQA->print_quality == BEST_QUALITY && m_pQA->media_type == MEDIATYPE_PHOTO)
748 *cur_pcl_buffer_ptr++ = 12;
750 *cur_pcl_buffer_ptr++ = 25;
751 *cur_pcl_buffer_ptr++ = 4; // Initial Print Speed
752 *cur_pcl_buffer_ptr++ = 1; // Need Accurate Position
753 if (m_lidil_version == 2)
755 *cur_pcl_buffer_ptr++ = 1; // Number of entries in the sweep
758 // fill in the color information
761 *cur_pcl_buffer_ptr++ = NO_ACTIVE_COLORS;
762 *cur_pcl_buffer_ptr++ = FRAME_SYN;
763 // write out the data
768 // figure out what are the active colors and fill in the optional color fields.
770 UInt16 colrpresent = 0;
772 UInt16 colormask = 0x01;
773 UInt16 offset = eLDLBlack;
776 uiAffectedColors = offset;
777 if (BlackPresent == true)
779 uiAffectedColors = 0x1;
781 if(BlackPresent == false && PhotoPresent == false)
785 uiAffectedColors |= 0x0000000e;
787 else if (BlackPresent == false && PhotoPresent == true)
789 if (ColorPresent == true)
793 uiAffectedColors |= 0x0000007e;
797 offset = eLDLLoBlack;
799 uiAffectedColors |= 0x00000070;
803 int actv_colr_index = cur_pcl_buffer_ptr - pcl_buffer;
805 if (m_lidil_version == 1)
807 cur_pcl_buffer_ptr += 2;
813 for(UInt16 i = offset; colr_found < colorcount && i < eLDLMaxColor; i++)
816 colrpresent = colrpresent | colormask;
818 if (m_lidil_version == 2)
820 addInt32 (uiAffectedColors);
823 addInt32 (RightEdge);
825 addInt32 (RightEdge);
827 if ((i == 0 && m_lidil_version == 1) || (BlackPresent && m_lidil_version == 2))
830 iPrintRes = m_iBlackPenResolution;
834 iDataRes = iColorRes; // 300;
835 iPrintRes = iColorRes; // 300;
837 addInt16 (iDataRes); // Vertical Data Resolution
838 addInt16 (iPrintRes); // Vertical Print Resolution
840 if (m_lidil_version == 2)
842 addInt16 (m_pQA->horizontal_resolution * m_iBitDepth); // Horizontal Data Resolution // Collie
846 addInt16 (m_pQA->horizontal_resolution);
849 if (m_pQA->horizontal_resolution == 300)
851 addInt16 (600); // Force 2 drop for draft mode.
855 if (m_lidil_version == 2)
857 addInt16 (m_pQA->horizontal_resolution * m_iBitDepth); // Horizontal Print Resolution // Collie
861 addInt16 (m_pQA->horizontal_resolution);
864 addInt16 (sFirstNozzle);
865 if (sLastNozzle == 0)
867 int iTmp = m_iRasterCount / m_pPM->dyeCount;;
868 if (m_lidil_version == 2)
870 addInt16 (sFirstNozzle - 1 + ((iTmp * iPrintRes) / (m_pQA->vertical_resolution * m_iBitDepth))); // Collie
874 addInt16 (sFirstNozzle - 1 + ((iTmp * iPrintRes) / (m_pQA->vertical_resolution)));
879 addInt16 (sLastNozzle);
882 *cur_pcl_buffer_ptr++ = 0; // Vertical Alignment
883 colormask = colormask << 1;
884 if (m_lidil_version == 2)
889 // write the active color field
890 if (m_lidil_version == 1)
892 BYTE *tmp = cur_pcl_buffer_ptr;
893 cur_pcl_buffer_ptr = pcl_buffer + actv_colr_index;
894 addInt16 (colrpresent);
895 cur_pcl_buffer_ptr = tmp;
898 if (m_lidil_version == 2)
900 *cur_pcl_buffer_ptr++ = 0; // # of entries in the shingle array
902 *cur_pcl_buffer_ptr++ = FRAME_SYN;
904 // write out the data
909 DRIVER_ERROR Lidil::allocateSwathBuffers()
911 int size = m_pMA->printable_width;
912 size = (size + 7) / 8;
913 m_iImageWidth = size;
914 m_ldlCompressData = NULL;
915 if (m_lidil_version == 1)
917 // m_ldlCompressData = new comp_ptrs_t;
920 if (m_iBitDepth == 2)
925 int iCompressBufSize = (m_iBytesPerSwing / 2) * LDL_MAX_IMAGE_SIZE+20; // additional space for load sweep command
926 m_szCompressBuf = new BYTE[iCompressBufSize];
927 if (m_szCompressBuf == NULL)
928 return ALLOCMEM_ERROR;
929 memset (m_szCompressBuf, 0, iCompressBufSize);
934 m_sSwathHeight = SWATH_HEIGHT;
937 * This swath buffer cannot be greater than the number of nozzles - 400 for black
938 * and 100 for color - we can use.
941 int iAdjHeight = (m_iNumBlackNozzles / 32) * 8;
942 if (m_pPM->dyeCount == 1)
944 m_sSwathHeight = m_sSwathHeight * 4;
945 if ((int) (m_sSwathHeight * 1200 / m_pQA->vertical_resolution) > m_iNumBlackNozzles)
946 m_sSwathHeight = m_pQA->vertical_resolution / 3;
948 else if (m_pQA->print_quality != DRAFT_QUALITY && m_pQA->vertical_resolution > 300 && m_pPM->dyeCount > 1 && m_iBitDepth == 1) // Collie change
950 m_sSwathHeight = (m_sSwathHeight / 4) * 4 * 2;
951 if (m_sSwathHeight > 200)
952 m_sSwathHeight = 200;
954 else if (m_iBitDepth == 2)
955 m_sSwathHeight = iAdjHeight * 4;
957 if (m_pQA->print_quality == NORMAL_QUALITY)
958 m_sSwathHeight = iAdjHeight * 2;
960 if (m_pQA->print_quality == DRAFT_QUALITY && m_pPM->dyeCount != 1)
962 m_sSwathHeight *= m_iBytesPerSwing / 2;
965 iSwathBuffSize = m_pPM->dyeCount * sizeof (BYTE *) +
966 m_pPM->dyeCount * m_sSwathHeight * sizeof (BYTE *) +
967 size * m_pPM->dyeCount * m_sSwathHeight;
968 if ((p = new BYTE[iSwathBuffSize]) == NULL)
970 return ALLOCMEM_ERROR;
974 m_SwathData = (BYTE ***) p;
975 for (i = 0; i < (int) m_pPM->dyeCount; i++)
976 m_SwathData[i] = (BYTE **) (p + sizeof (BYTE *) * m_pPM->dyeCount + i * m_sSwathHeight * sizeof (BYTE *));
978 for (i = 0; i < (int) m_pPM->dyeCount; i++)
980 p = (BYTE *) m_SwathData + sizeof (BYTE *) * m_pPM->dyeCount +
981 m_pPM->dyeCount * m_sSwathHeight * sizeof (BYTE *) +
982 size * m_sSwathHeight * i;
983 for (int j = 0; j < m_sSwathHeight; j++)
986 m_SwathData[i][j] = p;
991 if (m_pQA->print_quality != DRAFT_QUALITY && m_pQA->vertical_resolution != 300)
993 m_iRasterCount = (m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * m_pPM->dyeCount;
994 m_iVertPosn -= (((m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * 600 / m_pQA->vertical_resolution) * DEVUNITS_XBOW / 600);
998 if (m_pJA->print_borderless)
1000 if (m_iVertPosn < -850) m_iVertPosn = -850;
1004 if (m_iVertPosn < -600) m_iVertPosn = -600;
1006 if (m_iBitDepth == 2)
1011 unsigned int Lidil::getSwathWidth (int iStart, int iLast, int iWidth)
1015 for (i = iWidth - 1; i > -1; i--)
1017 for (j = iStart; j < iLast; j++)
1019 for (k = m_iRasterCount / m_pPM->dyeCount-1; k >= 0; k--)
1022 if (m_SwathData[j][k][i])
1033 DRIVER_ERROR Lidil::processSwath()
1035 DRIVER_ERROR err = NO_ERROR;
1036 Int16 sCurSwathHeight = m_iRasterCount / m_pPM->dyeCount;
1037 m_iVertPosn += ((m_iBlankRasters) * 600 / m_pQA->vertical_resolution) * DEVUNITS_XBOW / 600;
1038 m_iBlankRasters = 0;
1040 bool bColorPresent = true;
1041 bool bBlackPresent = true;
1042 bool bPhotoPresent = true;
1043 short sColorSize = 0;
1047 if (m_pPM->dyeCount == 1)
1049 bColorPresent = false;
1050 bPhotoPresent = false;
1052 if (m_pPM->dyeCount == 3)
1054 bBlackPresent = false;
1055 bPhotoPresent = false;
1057 if (m_pPM->dyeCount == 6)
1059 bBlackPresent = false;
1061 if (m_pPM->dyeCount == 4)
1063 bPhotoPresent = false;
1066 if (!m_bBidirectionalPrintingOn)
1067 m_cPrintDirection = PRNDRN_LEFTTORIGHT;
1069 int iStartRaster = m_cPassNumber % (2 * m_iBitDepth);
1072 if (m_lidil_version == 2)
1074 iStartRaster = 0; // Version 2 - REVISIT
1077 if (m_pQA->print_quality != DRAFT_QUALITY && m_pQA->vertical_resolution != 300)
1079 if ((m_cPassNumber % (4 * m_iBitDepth)) < (2 * m_iBitDepth))
1087 * Check if RefCount is close to overflow of 65k.
1090 if (m_sRefCount > 64000)
1097 err = processPhotoSwath(bPhotoPresent, bColorPresent, mask);
1098 if (err != NO_ERROR)
1105 err = processColorSwath(bPhotoPresent, bColorPresent, bBlackPresent, &sColorSize, mask);
1106 if (err != NO_ERROR)
1112 err = processBlackSwath(bBlackPresent, bColorPresent, sColorSize, LeftEdge, csavMask);
1116 if (m_pQA->print_quality != DRAFT_QUALITY && m_pQA->vertical_resolution != 300)
1118 m_cPassNumber = (m_cPassNumber + 1) % (4 * m_iBitDepth);
1119 m_iVertPosn += ((((sCurSwathHeight/(4 * m_iBitDepth))) * 600 / m_pQA->vertical_resolution) * DEVUNITS_XBOW / 600) / m_iBitDepth;
1120 if (m_iBitDepth == 1)
1122 if (m_cPassNumber % 2)
1130 if ((m_cPassNumber % 4) == 0)
1131 m_iVertPosn += (DEVUNITS_XBOW / m_iColorPenResolution);
1133 m_iRasterCount = (sCurSwathHeight - sCurSwathHeight / (4 * m_iBitDepth)) * m_pPM->dyeCount;
1137 m_iVertPosn += ((sCurSwathHeight * 4 * 600) / m_pQA->vertical_resolution);
1144 DRIVER_ERROR Lidil::processPhotoSwath(bool bPhotoPresent,
1153 BYTE csavMask = mask;
1161 DRIVER_ERROR err = NO_ERROR;
1162 int sCurSwathHeight = m_iRasterCount / m_pPM->dyeCount;
1163 unsigned int uiSwathSize;
1166 int iStartRaster = 0;
1171 int width = m_iImageWidth;
1177 if (m_lidil_version != 1)
1179 width *= m_iBitDepth;
1182 size = getSwathWidth (StartColor, LastColor, width);
1186 if (size % m_iBytesPerSwing)
1187 size = ((size/m_iBytesPerSwing) + 1) * m_iBytesPerSwing;
1188 if (m_lidil_version == 1)
1190 RightEdge = LeftEdge + (size * 8 * 600 / m_pQA->horizontal_resolution - 1 * (600 / m_pQA->vertical_resolution)) *
1191 (DEVUNITS_XBOW / 600);
1195 RightEdge = LeftEdge + (size * 8 * 600 / m_pQA->horizontal_resolution - 1 * (600 / m_pQA->vertical_resolution)) *
1196 (DEVUNITS_XBOW / (600 * m_iBitDepth));
1199 Int16 sFirstNozzle = 1;
1200 unsigned int uSweepSize;
1201 int jDelta = m_pQA->vertical_resolution / m_iColorPenResolution;
1202 jDelta *= m_iBitDepth;
1204 uiSwathSize = size * iColors * sCurSwathHeight / jDelta;
1206 uSweepSize = sCurSwathHeight * m_iBytesPerSwing / jDelta;
1207 n = LDL_MAX_IMAGE_SIZE / (uSweepSize);
1210 if (m_iBitDepth == 2)
1211 iStartRaster = (4 - (iStartRaster+1)) % 4;
1213 if (m_lidil_version == 2)
1215 iStartRaster = 0; // Collie - REVISIT
1218 sLastNozzle = sFirstNozzle - 1 + sCurSwathHeight / jDelta;
1220 BYTE *cb = m_szCompressBuf + 16; // load sweep command
1221 memset (m_szCompressBuf, 0x0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1223 // 1200 dpi split into two
1226 if (m_pQA->vertical_resolution > 300 && m_pQA->print_quality != DRAFT_QUALITY)
1228 iOffset = (sCurSwathHeight / (4 * m_iBitDepth));
1229 iOffset = iOffset + iOffset * ((m_cPassNumber) % (4 * m_iBitDepth));
1232 BYTE cVertAlign = 0;
1236 cVertAlign = m_cPtoCVertAlign;
1239 for (ib = 0; ib < (int) m_iBitDepth; ib++)
1241 if (m_cPrintDirection == PRNDRN_RIGHTTOLEFT)
1243 start = size - m_iBytesPerSwing;
1244 delta = -m_iBytesPerSwing;
1249 delta = m_iBytesPerSwing;
1252 err = printSweep (uiSwathSize, bColorPresent, false, bPhotoPresent,
1253 m_iVertPosn+cVertAlign, LeftEdge, RightEdge, m_cPrintDirection,
1254 sFirstNozzle, sLastNozzle);
1257 i = start + ib * m_iImageWidth; // 1200 dpi split into two
1258 for (int l = 0; l < size; l += m_iBytesPerSwing) // Collie
1260 for (int k = StartColor+1; k < LastColor; k++)
1263 for (j = iOffset + iStartRaster; j < sCurSwathHeight; j += jDelta)
1265 for (int is = 0; is < m_iBytesPerSwing; is++)
1267 *cb++ = m_SwathData[k][j][i+is] & mask;
1271 for (j = iStartRaster; j < iOffset; j += jDelta)
1273 for (int is = 0; is < m_iBytesPerSwing; is++)
1275 *cb++ = m_SwathData[k][j][i+is] & mask;
1283 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1284 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1285 cb = m_szCompressBuf+16;
1291 for (j = iOffset + iStartRaster; j < sCurSwathHeight; j += jDelta)
1293 for (int is = 0; is < m_iBytesPerSwing; is++)
1295 *cb++ = m_SwathData[0][j][i + is] & mask;
1299 for (j = iStartRaster; j < iOffset; j += jDelta)
1301 for (int is = 0; is < m_iBytesPerSwing; is++)
1303 *cb++ = m_SwathData[0][j][i + is] & mask;
1311 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1312 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1313 cb = m_szCompressBuf+16;
1321 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1322 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1323 cb = m_szCompressBuf+16;
1328 if (m_bBidirectionalPrintingOn)
1329 m_cPrintDirection = (m_cPrintDirection + 1) % 2;
1331 if (m_lidil_version == 2) // Collie
1338 } // 1200 dpi split into two - end of for ib = 0 loop
1342 DRIVER_ERROR Lidil::processColorSwath(bool bPhotoPresent,
1348 BYTE csavMask = mask;
1349 int iStartRaster = 0;
1360 DRIVER_ERROR err = NO_ERROR;
1361 int sCurSwathHeight = m_iRasterCount / m_pPM->dyeCount;
1362 unsigned int uiSwathSize;
1363 if (bPhotoPresent || !bColorPresent)
1376 if (m_lidil_version == 1)
1378 // 1200 dpi split into two
1379 size = getSwathWidth (StartColor, LastColor, m_iImageWidth/* * m_iBitDepth*/);
1383 size = getSwathWidth (StartColor, LastColor, m_iImageWidth * m_iBitDepth);
1391 if (size % m_iBytesPerSwing)
1392 size = ((size / m_iBytesPerSwing) + 1) * m_iBytesPerSwing;
1394 if (m_lidil_version == 1)
1396 RightEdge = LeftEdge + (size * 8 * 600 / m_pQA->horizontal_resolution - 1 * (600 / m_pQA->vertical_resolution)) *
1397 (DEVUNITS_XBOW / 600);
1401 RightEdge = LeftEdge + (size * 8 * 600 / m_pQA->horizontal_resolution - 1 * (600 / m_pQA->vertical_resolution)) *
1402 (DEVUNITS_XBOW / (600 * m_iBitDepth));
1405 Int16 sFirstNozzle = 1;
1406 unsigned int uSweepSize;
1407 int jDelta = m_pQA->vertical_resolution / m_iColorPenResolution;
1408 jDelta *= m_iBitDepth;
1410 uiSwathSize = size * iColors * sCurSwathHeight / jDelta;
1412 uSweepSize = sCurSwathHeight * m_iBytesPerSwing / jDelta;
1413 n = LDL_MAX_IMAGE_SIZE / (uSweepSize);
1416 if (m_iBitDepth == 2)
1418 iStartRaster = (4 - (iStartRaster+1)) % 4;
1419 if (m_lidil_version == 2)
1421 iStartRaster = m_cPassNumber % (m_iBitDepth);
1425 sLastNozzle = sFirstNozzle - 1 + sCurSwathHeight / jDelta;
1427 BYTE *cb = m_szCompressBuf + 16; // load sweep command
1428 memset (m_szCompressBuf, 0x0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1430 // 1200 dpi split into two
1433 if (m_pQA->vertical_resolution > 300 && m_pQA->print_quality != DRAFT_QUALITY)
1435 iOffset = (sCurSwathHeight / (4 * m_iBitDepth));
1436 iOffset = iOffset + iOffset * ((m_cPassNumber) % (4 * m_iBitDepth));
1439 for (ib = 0; ib < (int) m_iBitDepth; ib++)
1441 if (m_cPrintDirection == PRNDRN_RIGHTTOLEFT)
1443 start = size - m_iBytesPerSwing;
1444 delta = -m_iBytesPerSwing;
1449 delta = m_iBytesPerSwing;
1451 err = printSweep (uiSwathSize, bColorPresent, false, false,
1452 m_iVertPosn, LeftEdge, RightEdge, m_cPrintDirection,
1453 sFirstNozzle, sLastNozzle);
1456 i = start + ib * m_iImageWidth; // 1200 dpi split into two
1457 for (int l = 0; l < size; l += m_iBytesPerSwing) // Collie
1459 for (int k = StartColor; k < LastColor; k++)
1462 for (j = iOffset + iStartRaster; j < sCurSwathHeight; j += jDelta)
1464 for (int is = 0; is < m_iBytesPerSwing; is++)
1466 *cb++ = m_SwathData[k][j][i + is] & mask;
1470 for (j = iStartRaster; j < iOffset; j += jDelta)
1472 for (int is = 0; is < m_iBytesPerSwing; is++)
1474 *cb++ = m_SwathData[k][j][i + is] & mask;
1482 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1483 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1485 cb = m_szCompressBuf+16;
1496 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1497 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1499 cb = m_szCompressBuf+16;
1507 if (m_bBidirectionalPrintingOn)
1508 m_cPrintDirection = (m_cPrintDirection + 1) % 2;
1509 if (m_lidil_version == 2) // Collie
1514 } // 1200 dpi split into two - end of for ib = 0 loop
1518 DRIVER_ERROR Lidil::processBlackSwath(bool bBlackPresent,
1532 DRIVER_ERROR err = NO_ERROR;
1533 int sCurSwathHeight = m_iRasterCount / m_pPM->dyeCount;
1534 unsigned int uiSwathSize;
1540 int size = getSwathWidth (0, 1, m_iImageWidth);
1544 if (size % m_iBytesPerSwing)
1545 size = ((size/m_iBytesPerSwing) + 1) * m_iBytesPerSwing;
1547 RightEdge = LeftEdge + (size * 8 * 600 / m_pQA->horizontal_resolution - 1 * (600 / m_pQA->vertical_resolution)) * DEVUNITS_XBOW/600;
1548 if (m_iBitDepth != 2 && ((m_cPassNumber % 2) == 0 || m_pQA->print_quality == DRAFT_QUALITY))
1550 Int16 sLastNozzle = 0;
1551 Int16 sFirstNozzle = 1;
1554 BYTE cVertAlign = 0;
1558 cVertAlign = m_cKtoCVertAlign;
1561 if (bColorPresent && sColorSize && m_bBidirectionalPrintingOn)
1562 m_cPrintDirection = PRNDRN_RIGHTTOLEFT;
1563 if (m_cPrintDirection == PRNDRN_RIGHTTOLEFT)
1565 start = size - m_iBytesPerSwing;
1566 delta = -m_iBytesPerSwing;
1571 delta = m_iBytesPerSwing;
1573 if (m_pQA->vertical_resolution == 300)
1574 xDelta = m_iBytesPerSwing;
1575 uiSwathSize = ((size/m_iBytesPerSwing) * sCurSwathHeight * m_iBytesPerSwing * (600 * m_iBitDepth)/ m_pQA->vertical_resolution);
1577 if (m_lidil_version == 2 && m_pPM->dyeCount != 1)
1582 err = printSweep (uiSwathSize, false, bBlackPresent, false,
1583 (m_iVertPosn + cVertAlign), LeftEdge, RightEdge, m_cPrintDirection, sFirstNozzle, sLastNozzle);
1587 BYTE *cb = m_szCompressBuf+16;
1588 memset (m_szCompressBuf, 0x0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1590 n = LDL_MAX_IMAGE_SIZE / (sCurSwathHeight * m_iBytesPerSwing * 600 / m_pQA->vertical_resolution);
1593 if (m_pQA->vertical_resolution > 300 && m_pQA->print_quality != DRAFT_QUALITY)
1595 iOffset = sCurSwathHeight / 4;
1596 iOffset = iOffset + iOffset * (m_cPassNumber % 4);
1599 for (int l = 0; l < size; l += m_iBytesPerSwing) // Collie
1601 for (j = iOffset; j < sCurSwathHeight; j++)
1603 for (int is = 0; is < m_iBytesPerSwing; is++)
1605 *cb++ = m_SwathData[0][j][i + is] & mask;
1609 for (j = 0; j < iOffset; j++)
1611 for (int is = 0; is < m_iBytesPerSwing; is++)
1613 *cb++ = m_SwathData[0][j][i + is] & mask;
1621 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1622 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1624 cb = m_szCompressBuf+16;
1632 err = loadSweepData (m_szCompressBuf, (unsigned int) (cb - m_szCompressBuf-16));
1633 memset (m_szCompressBuf, 0, LDL_MAX_IMAGE_SIZE * (m_iBytesPerSwing / 2));
1635 cb = m_szCompressBuf+16;
1640 if (m_bBidirectionalPrintingOn)
1641 m_cPrintDirection = (m_cPrintDirection + 1) % 2;
1646 bool Lidil::isBlankRaster(BYTE *raster, int width)
1648 if (*raster == 0 && !memcmp(raster+1, raster, width-1))
1653 void Lidil::applyShingleMask(int iCPlane, BYTE *input)
1655 // do the dotmapping here
1656 BYTE cbyte1, cbyte2;
1663 BYTE bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
1666 int iNextBitPos = m_iImageWidth;
1667 int iJIncrement = 1;
1668 if (m_lidil_version == 2)
1675 memcpy (m_szCompressBuf, m_SwathData[iCPlane][m_iNextRaster], m_iImageWidth);
1677 static BYTE rand_table[4][4] = {{0, 3, 1, 2},
1683 rt1 = m_iNextRaster % 4;
1685 for (int i = 0; i < m_iImageWidth; i++)
1687 cbyte2 = m_szCompressBuf[i];
1688 cbyte1 = (input == NULL) ? 0 : input[i];
1690 // 1200 dpi raster split into 2 600 dpi rasters
1697 for (int ibit = 0; ibit < 8; ibit++)
1699 c1 = (cbyte1 & bitmask[ibit]) ? 1 : 0;
1700 c2 = (cbyte2 & bitmask[ibit]) ? 1 : 0;
1703 rt2 = (i + ibit) % 4;
1704 rt2 = rand_table[rt1][rt2];
1710 r1b1 = r1b1 | (0xff & (cbyte1 & bitmask[ibit]));
1711 r2b2 = r2b2 | (0xff & bitmask[ibit]);
1715 r1b2 = r1b2 | (0xff & bitmask[ibit]);
1716 r2b1 = r2b1 | (0xff & bitmask[ibit]);
1721 r1b1 = r1b1 | (0xff & bitmask[ibit]);
1722 r2b1 = r2b1 | (0xff & bitmask[ibit]);
1726 r1b2 = r1b2 | (0xff & bitmask[ibit]);
1727 r2b2 = r2b2 | (0xff & bitmask[ibit]);
1734 r1b1 = r1b1 | (0xff & bitmask[ibit]);
1736 r1b2 = r1b2 | (0xff & bitmask[ibit]);
1738 r2b1 = r2b1 | (0xff & bitmask[ibit]);
1740 r2b2 = r2b2 | (0xff & bitmask[ibit]);
1745 r1b1 = r1b1 | (0xff & bitmask[ibit]);
1746 r1b2 = r1b2 | (0xff & bitmask[ibit]);
1747 r2b1 = r2b1 | (0xff & bitmask[ibit]);
1748 r2b2 = r2b2 | (0xff & bitmask[ibit]);
1751 m_SwathData[iCPlane][m_iNextRaster][j] = r1b1;
1752 m_SwathData[iCPlane][m_iNextRaster][j+iNextBitPos] = r1b2;
1753 m_SwathData[iCPlane][m_iNextRaster+1][j] = r2b1;
1754 m_SwathData[iCPlane][m_iNextRaster+1][j+iNextBitPos] = r2b2;