10 #include "evoliserror.h"
\r
13 #define RgbToGray(r, g, b) (((long) (r)*74L + (long)(g)*155L +(long)(b)*27L) >> 8)
\r
16 int STATUS=0; //0 means succes, 1 means failure
\r
17 unsigned char *lpMem;
\r
18 unsigned char *lpRecto,*lpVerso;
\r
19 int Model; /* Model number */
\r
20 long dwSizeNeeded; // taille mmoire du lpMem en octets
\r
25 OverlayBackPannel[10],
\r
34 int Brightness, Contrast, SensibilityK, QualityK, SensibilityO;
\r
35 int TB,LB,BB,RB,TW,LW,BW,RW;
\r
36 int DetectAuto,StartDist;
\r
37 int colorspace,levelB;
\r
42 int DitherPattern1[8][8] = {
\r
43 {0, 112, 28, 140, 7, 119, 35, 147},
\r
44 {168, 56, 196, 84, 175, 63, 203, 78},
\r
45 {42, 154, 14, 126, 49, 161, 21, 114},
\r
46 {210, 98, 182, 70, 217, 105, 189, 77},
\r
47 {11, 123, 39, 151, 4, 116, 32, 143},
\r
48 {179, 67, 207, 95, 172, 59, 200, 88},
\r
49 {53, 165, 24, 137, 46, 158, 18, 111},
\r
50 {221, 109, 193, 81, 214, 102, 159, 74}
\r
55 // Compress and format data for the printer
\r
56 long ReduceBlack(unsigned char *lpMemIn, unsigned char *lpMemOut,int nbrline);
\r
57 long ReduceColor(unsigned char *lpMemIn, unsigned char *lpMemOut, int uiBitComp);//,int nbrline);
\r
58 //int CutPage(long *stop);
\r
60 // Download functions
\r
61 int DBNC(int col,int bl,int ov);//,int line);
\r
62 int DB32NC(long lPos, char color); //y,m,c pannels 5 bits per color
\r
63 int DB64NC(long lPos, char color); //y,m,c pannels 6 bits per color
\r
64 int DB128NC(long lPos, char color); //y,m,c pannels 7 bits per color
\r
65 /*int DB32NCS(long lPos, char color,int line); //y,m,c pannels 5 bits per color
\r
66 int DB64NCS(long lPos, char color,int line); //y,m,c pannels 6 bits per color
\r
67 int DB128NCS(long lPos, char color,int line); //y,m,c pannels 7 bits per color*/
\r
68 int DB2NC(long lPos, char pannel[10]); // k,o panel 2 levels
\r
69 int DB2MNC(long lPos); // k panel 2 levels
\r
71 // Convert RVB to k functions
\r
72 void RVBtoGray(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte);
\r
73 void KinYMC(long Height, long Width);
\r
74 void GrayToFloyd(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height);
\r
75 void GrayToDither(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height);
\r
76 void GrayToThreshold(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte);
\r
77 void ConvertRVBtoK(unsigned char *lpbRVB, long RVBSize, long Height, long Width, unsigned char *lpBlack);
\r
78 void GetFirstYMCDot(long Height, long Width , int *x, int *y);
\r
81 //===============================================================================//
\r
82 // Reduce color data from 8 bits to uiBitComp.
\r
84 // Entree : 1 color panel (1016 * 648 octets)
\r
85 // Sortie : 1 color panel with usable data ((1016*648)*uiBitComp)/8
\r
86 //===============================================================================//
\r
89 long ReduceColor(unsigned char *lpMemIn, unsigned char *lpMemOut, int uiBitComp)//,int nbrline)
\r
91 long lIndex = 0, lIndex1 = 0;
\r
92 unsigned char *lpbBuf, *lpbData, *lpbDataOut;
\r
94 long lNbrByte = (1016*648);
\r
96 //Reservation m�oire pour traitement d'une ligne
\r
103 //fprintf(stderr, "**************** EVOLIS ReduceColor manque de memoire pour lpBuf: taille demande 8 octets... \n");
\r
104 fatal("ReduceColor Fails memory lpBuf: requested size 8 bytes...");
\r
106 /// sortir de l'impression....
\r
110 //lpbData ppV mem bmp brute
\r
111 lpbData = &lpMemIn[0];
\r
113 lpbDataOut = &lpMemOut[0];
\r
114 // pour toutes les donnees
\r
115 while (lIndex < lNbrByte)
\r
117 //Traite byte par 8
\r
118 for (lIndex1 = 0; lIndex1 < 8; lIndex1++)
\r
120 if (lIndex < lNbrByte)
\r
122 //decalage donnees utiles
\r
123 lpbBuf[lIndex1] = *(lpbData++) >> (8 - uiBitComp);
\r
129 lpbBuf[lIndex1] = 0x00;
\r
136 *(lpbDataOut++) = (lpbBuf[0] << 2) | (lpbBuf[1] >> 4);
\r
137 *(lpbDataOut++) = (lpbBuf[1] << 4) | (lpbBuf[2] >> 2);
\r
138 *(lpbDataOut++) = (lpbBuf[2] << 6) | (lpbBuf[3]);
\r
139 *(lpbDataOut++) = (lpbBuf[4] << 2) | (lpbBuf[5] >> 4);
\r
140 *(lpbDataOut++) = (lpbBuf[5] << 4) | (lpbBuf[6] >> 2);
\r
141 *(lpbDataOut++) = (lpbBuf[6] << 6) | (lpbBuf[7]);
\r
144 *(lpbDataOut++) = (lpbBuf[0] << 1) | (lpbBuf[1] >> 6);
\r
145 *(lpbDataOut++) = (lpbBuf[1] << 2) | (lpbBuf[2] >> 5);
\r
146 *(lpbDataOut++) = (lpbBuf[2] << 3) | (lpbBuf[3] >> 4);
\r
147 *(lpbDataOut++) = (lpbBuf[3] << 4) | (lpbBuf[4] >> 3);
\r
149 *(lpbDataOut++) = (lpbBuf[4] << 5) | (lpbBuf[5] >> 2);
\r
150 *(lpbDataOut++) = (lpbBuf[5] << 6) | (lpbBuf[6] >> 1);
\r
151 *(lpbDataOut++) = (lpbBuf[6] << 7) | (lpbBuf[7]);
\r
155 *(lpbDataOut++) = (lpbBuf[0] << 3) | (lpbBuf[1] >> 2);
\r
156 *(lpbDataOut++) = (lpbBuf[1] << 6) | (lpbBuf[2] << 1) | (lpbBuf[3] >> 4);
\r
157 *(lpbDataOut++) = (lpbBuf[3] << 4) | (lpbBuf[4] >> 1);
\r
159 *(lpbDataOut++) = (lpbBuf[4] << 7) | (lpbBuf[5] << 2) | (lpbBuf[6] >> 3);
\r
160 *(lpbDataOut++) = (lpbBuf[6] << 5) | (lpbBuf[7]);
\r
165 lComp = (((lNbrByte * 10) / 8) * uiBitComp);
\r
174 //===================================================//
\r
175 // fonction pour le panneau noir & overlay uniquement
\r
176 // entree : 1 octect = 1 points
\r
177 // sortie : 1 octect = 8 points
\r
178 //===================================================//
\r
179 long ReduceBlack(unsigned char *lpMemIn, unsigned char *lpMemOut,int nbrline)
\r
181 long lIndex = 0, lIndex1 = 0;
\r
182 unsigned char *lpbData, *lpbDataOut;
\r
184 unsigned char bBuf = 0x00;
\r
186 unsigned char Mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
\r
187 long lNbrByte = nbrline * 648;
\r
190 //lpbData ppV mem bmp brute
\r
191 lpbData = &lpMemIn[0];
\r
192 lpbDataOut = &lpMemOut[0];
\r
193 // pour toutes les donnees
\r
195 while (lIndex < lNbrByte)
\r
199 //Traite byte par 8
\r
200 for (lIndex1 = 0; lIndex1 < 8; lIndex1++)
\r
203 if (lIndex < lNbrByte)
\r
205 if (*(lpbData++) == 0xFF)
\r
207 bBuf |= Mask[lIndex1];
\r
212 *(lpbDataOut++) = bBuf;
\r
219 //=====================================================================
\r
220 // Convert bitmap RVB data to evolis data format
\r
221 //=====================================================================
\r
224 int DBNC(int col,int bl,int ov)//,int line)
\r
226 //output("\033Ss\015"); // debut sequence + CR
\r
229 DB32NC(0 * (dwSizeNeeded / 5), 'y');
\r
230 DB32NC(1 * (dwSizeNeeded / 5), 'm');
\r
231 DB32NC(2 * (dwSizeNeeded / 5), 'c');
\r
233 else if (col == 2) {
\r
234 DB64NC(0 * (dwSizeNeeded / 5), 'y');
\r
235 DB64NC(1 * (dwSizeNeeded / 5), 'm');
\r
236 DB64NC(2 * (dwSizeNeeded / 5), 'c');
\r
238 else if (col == 3) {
\r
239 DB128NC(0 * (dwSizeNeeded / 5), 'y');
\r
240 DB128NC(1 * (dwSizeNeeded / 5), 'm');
\r
241 DB128NC(2 * (dwSizeNeeded / 5), 'c');
\r
245 DB2NC(3 * (dwSizeNeeded / 5), "ABP");
\r
249 if(ov == 1){//overlay at front
\r
250 DB2NC(0, OverlayPannel);
\r
253 DB2NC(0, OverlayBackPannel);
\r
258 //output("\033Se\015....................................."); // fin sequence + CR
\r
262 //===============================================================//
\r
263 // Telechargement d'un panneau non compresse 5 bits
\r
264 // Input : ucData / raw data
\r
265 // color /y,m or c
\r
267 // -1 si erreur ecriture
\r
268 //===============================================================//
\r
269 int DB32NC(long lPos, char color)
\r
271 unsigned char *ucCommand, *ucCol;
\r
272 long lCommandSize = ((1016 * 648) * 5) / 8;
\r
274 int numwritten = 0;
\r
276 //Reservation memoire pour une commande de telechargement
\r
277 ucCommand = malloc(lCommandSize + 12);
\r
279 fatal("DP32NC Error: Fails malloc... ");
\r
283 ucCol = &lpMem[lPos];
\r
284 strcpy(ucCommand, "\033Db;y;32;");
\r
285 strncpy(&ucCommand[4], &color, 1);
\r
287 lComp = ReduceColor(ucCol, &ucCommand[9], 5);//,1016);
\r
288 lCommandSize += 10;
\r
290 if (color=='y') info("Download Yellow color");
\r
291 else if (color=='m') info("Download Magenta color");
\r
292 else if (color=='c') info("Download Cyan color");
\r
294 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
295 if (numwritten != lCommandSize) {
\r
296 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
\r
301 while(lComp > 4096) {
\r
302 numwritten += fwrite(&ucCommand[numwritten], sizeof(unsigned char), 4096, stdout);
\r
305 debug("NuwWritten %d", numwritten);
\r
307 numwritten += fwrite(&ucCommand[numwritten], sizeof(unsigned char), lComp, stdout);
\r
309 debug("lComp %d numwritten %d lCommandSize %d", lComp,numwritten,lCommandSize);
\r
310 if (numwritten != lCommandSize) {
\r
311 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
\r
321 //===============================================================//
\r
322 // Telechargement d'un panneau non compresse 6 bits
\r
323 // Input : ucData / raw data
\r
324 // color /y,m or c
\r
326 // -1 si erreur ecriture
\r
327 //===============================================================//
\r
329 int DB64NC(long lPos, char color)
\r
331 unsigned char *ucCommand, *ucCol;
\r
334 long lCommandSize = ((1016 * 648) * 6) / 8;
\r
336 int numwritten = 0;
\r
339 //Reservation memoire pour une commande de telechargement
\r
340 ucCommand = malloc(lCommandSize + 10);
\r
341 debug("DP64NC Size for one panel: %d... \n", (lCommandSize + 10));
\r
346 fatal("DP64NC Error: Fails malloc...");
\r
352 ucCol = &lpMem[lPos];
\r
353 strcpy(ucCommand, "\033Db;y;64;");
\r
354 strncpy(&ucCommand[4], &color, 1);
\r
357 lComp = ReduceColor(ucCol, &ucCommand[9], 6);//,1016);
\r
358 //fprintf(stderr, "**************** EVOLIS DP64NC taille apres compression %d... \n",lComp);
\r
359 strncpy(&ucCommand[lCommandSize + 9], "\015", 1);
\r
360 lCommandSize += 10;
\r
362 if (color=='y') info("Download Yellow color");
\r
363 else if (color=='m') info("Download Magenta color");
\r
364 else if (color=='c') info("Download Cyan color");
\r
367 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
368 if (numwritten != lCommandSize)
\r
370 fatal("DP64NC Error: Fails fwrite %d... \n", numwritten);
\r
382 //===============================================================//
\r
383 // Telechargement d'un panneau non compresse 7 bits
\r
384 // Input : ucData / raw data
\r
385 // color /y,m or c
\r
387 // -1 si erreur ecriture
\r
388 //===============================================================//
\r
389 int DB128NC(long lPos, char color)
\r
392 unsigned char *ucCommand, *ucCol;
\r
393 long lCommandSize = ((1016 * 648) * 7) / 8;
\r
395 int numwritten = 0;
\r
397 //Reservation memoire pour une commande de telechargement
\r
398 ucCommand = malloc(lCommandSize + 11);
\r
399 debug("DP128NC Size for one panel: %d... ", (lCommandSize + 11));
\r
402 fatal("DP128NC Error: Fails malloc... ");
\r
407 ucCol = &lpMem[lPos];
\r
408 strcpy(ucCommand, "\033Db;y;128;");
\r
409 strncpy(&ucCommand[4], &color, 1);
\r
410 lComp = ReduceColor(ucCol, &ucCommand[10], 7);//,1016);
\r
411 strncpy(&ucCommand[lCommandSize + 10], "\015", 1);
\r
412 lCommandSize += 11;
\r
414 if (color=='y') info("Download Yellow color");
\r
415 else if (color=='m') info("Download Magenta color");
\r
416 else if (color=='c') info("Download Cyan color");
\r
418 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
419 if (numwritten != lCommandSize)
\r
421 fatal("DP128NC Error: Fails fwrite %d... \n", numwritten);
\r
429 //===============================================================//
\r
430 // Telechargement d'un panneau non compresse 5 bits YMCKOS
\r
431 // Input : ucData / raw data
\r
434 // -1 si erreur ecriture
\r
435 //===============================================================//
\r
436 /*int DB32NCS(long lPos, char color,int line)
\r
438 unsigned char *ucCommand, *ucCol;
\r
439 long lCommandSize = ((1016 * 648) * 5) / 8;
\r
441 int numwritten = 0;
\r
443 //Reservation memoire pour une commande de telechargement
\r
444 ucCommand = malloc(lCommandSize + 20);
\r
445 //fprintf(stderr, "**************** EVOLIS DP32NC Size for one panel: %d... \n", (lCommandSize+10));
\r
448 //fprintf(stderr, "**************** EVOLIS DP32NC Error: Fails malloc... \n");
\r
449 fatal("DP32NC Error: Fails malloc... ");
\r
453 ucCol = &lpMem[lPos];
\r
454 //strcpy(ucCommand, "\033Dbc;y;32;");
\r
455 //nbroct = 540 * 648;
\r
456 lCommandSize = ((520 * 648) * 5) / 8;
\r
457 sprintf(ucCommand, "\033Dbc;y;32;%.4d;%.6d;",line,lCommandSize);
\r
458 strncpy(&ucCommand[5], &color, 1);
\r
460 info("%s",ucCommand);
\r
461 lComp = ReduceColor(ucCol, &ucCommand[22], 5, 520);
\r
462 strncpy(&ucCommand[lCommandSize + 22], "\015", 1);
\r
463 lCommandSize += 23;
\r
465 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
466 //info("%d %s", numwritten,ucCommand);
\r
467 if (numwritten != lCommandSize)
\r
469 //fprintf(stderr, "**************** EVOLIS DP32NC Error: Fails printf %d... \n",numwritten);
\r
470 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
\r
478 //===============================================================//
\r
479 // Telechargement d'un panneau non compresse 6 bits YMCKOS
\r
480 // Input : ucData / raw data
\r
483 // -1 si erreur ecriture
\r
484 //===============================================================//
\r
486 int DB64NCS(long lPos, char color,int line)
\r
488 unsigned char *ucCommand, *ucCol;
\r
490 long lCommandSize = ((1016 * 648) * 6) / 8;
\r
492 int numwritten = 0;
\r
496 //Reservation memoire pour une commande de telechargement
\r
497 ucCommand = malloc(lCommandSize + 10);
\r
498 debug("DP64NC Size for one panel: %d... \n", (lCommandSize + 10));
\r
503 fatal("DP64NC Error: Fails malloc...");
\r
509 ucCol = &lpMem[lPos];
\r
510 strcpy(ucCommand, "\033Db;y;64;");
\r
511 strncpy(&ucCommand[4], &color, 1);
\r
514 lComp = ReduceColor(ucCol, &ucCommand[9], 6, 540);
\r
515 //fprintf(stderr, "**************** EVOLIS DP64NC taille apres compression %d... \n",lComp);
\r
516 strncpy(&ucCommand[lCommandSize + 9], "\015", 1);
\r
517 lCommandSize += 10;
\r
518 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
519 if (numwritten != lCommandSize)
\r
521 fatal("DP64NC Error: Fails fwrite %d... \n", numwritten);
\r
533 //===============================================================//
\r
534 // Telechargement d'un panneau non compresse 7 bits YMCKOS
\r
535 // Input : ucData / raw data
\r
538 // -1 si erreur ecriture
\r
539 //===============================================================//
\r
540 int DB128NCS(long lPos, char color,int line)
\r
543 unsigned char *ucCommand, *ucCol;
\r
544 long lCommandSize = ((1016 * 648) * 7) / 8;
\r
546 int numwritten = 0;
\r
548 //Reservation memoire pour une commande de telechargement
\r
549 ucCommand = malloc(lCommandSize + 11);
\r
550 //fprintf(stderr, "**************** EVOLIS DP128NC Size for one panel: %d... \n", (lCommandSize+11));
\r
551 debug("DP128NC Size for one panel: %d... ", (lCommandSize + 11));
\r
556 fatal("DP128NC Error: Fails malloc... ");
\r
561 ucCol = &lpMem[lPos];
\r
562 strcpy(ucCommand, "\033Db;y;128;");
\r
563 strncpy(&ucCommand[4], &color, 1);
\r
564 lComp = ReduceColor(ucCol, &ucCommand[10], 7, 540);
\r
565 //fprintf(stderr, "**************** EVOLIS DP128NC taille apres compression %d... \n",lComp);
\r
566 strncpy(&ucCommand[lCommandSize + 10], "\015", 1);
\r
567 lCommandSize += 11;
\r
568 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
569 if (numwritten != lCommandSize)
\r
571 fatal("DP128NC Error: Fails fwrite %d... \n", numwritten);
\r
579 //===============================================================//
\r
580 // Telechargement d'un panneau non compresse overlay noir
\r
581 // Input : ucData / raw datal978
\r
583 // f: full varnish
\r
585 // -1 si erreur ecriture
\r
586 //===============================================================//
\r
588 int DB2NC(long lPos, char pannel[10])
\r
590 unsigned char *ucCommand, *ucCol;
\r
593 long lCommandSize = ((1016 * 648)) / 8;
\r
594 int numwritten = 0;
\r
595 int B, T, L, R, i = 0, j = 0;
\r
596 int pB, pT, ModuloB, ModuloT;
\r
598 //unsigned char MaskB[8] = { 0x00,0x80,0xC0,0xE0,0xF0,0x7F,0x3F,0x1F};
\r
599 //unsigned char MaskT[8] = { 0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F};
\r
600 unsigned char MaskB[8] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
\r
601 unsigned char MaskT[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
\r
604 //Reservation memoire pour une commande de telechargement
\r
606 ucCommand = malloc(lCommandSize + 9);
\r
608 //debug("DP2NC Size for one panel: %d... ", (lCommandSize + 9));
\r
613 fatal("DP2NC Error: Fails malloc... ");
\r
618 if (!(strcmp(pannel, "ABP")))// == NULL)
\r
620 ucCol = &lpMem[lPos];
\r
621 strcpy(ucCommand, "\033Db;k;2;");
\r
622 lComp = ReduceBlack(ucCol, &ucCommand[8],1016);
\r
623 strncpy(&ucCommand[lCommandSize + 8], "\015", 1);
\r
626 info("Download Black");
\r
627 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
628 if (numwritten != lCommandSize)
\r
630 fatal("DP2NC Error: Fails fprintf %d... ", numwritten);
\r
636 else if (!(strcmp(pannel, "NO")))// == NULL)
\r
638 memset(ucCommand, 0x00, lCommandSize);
\r
639 strcpy(ucCommand, "\033Db;o;2;");
\r
640 strncpy(&ucCommand[lCommandSize + 8], "\015", 1);
\r
642 info("Download varnish - statut : no varnish");
\r
643 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
644 if (numwritten != lCommandSize)
\r
646 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
\r
651 else if (!(strcmp(pannel, "FO")))// == NULL)
\r
653 memset(ucCommand, 0xFF, lCommandSize);
\r
654 strcpy(ucCommand, "\033Db;o;2;");
\r
655 strncpy(&ucCommand[lCommandSize + 8], "\015", 1);
\r
657 info("Download varnish - statut : full varnish");
\r
658 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
659 if (numwritten != lCommandSize)
\r
661 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
\r
669 if (!(strcmp(pannel, "OA")))// == NULL)
\r
676 debug("DP2NC OA... ");
\r
677 memset(ucCommand, 0x00, lCommandSize);
\r
680 for (j = L; j <= R; j++)
\r
683 pB = (j * 648) + (648 - B);
\r
688 ucCommand[pB + 7] = MaskB[ModuloB];
\r
690 pT = (j * 648) + (648 - T);
\r
695 ucCommand[pT + 7] = MaskT[ModuloT];
\r
697 for (i = (pB); i <= (pT); i++)
\r
699 ucCommand[i + 7] = 0xFF;
\r
707 else if (!(strcmp(pannel, "SCI")))// == NULL)
\r
714 memset(ucCommand, 0xFF, lCommandSize);
\r
715 debug("DP2NC SCI... ");
\r
717 else if (!(strcmp(pannel, "SCA")))// == NULL)
\r
724 memset(ucCommand, 0xFF, lCommandSize);
\r
725 debug("DP2NC SCA... ");
\r
727 else if (!(strcmp(pannel, "MS")))// == NULL)
\r
734 memset(ucCommand, 0xFF, lCommandSize);
\r
735 debug("DP2NC MS... ");
\r
738 for (j = L; j <= R; j++)
\r
740 pB = (j * 648) + (648 - B);
\r
745 ucCommand[pB + 7] = MaskB[ModuloB];
\r
747 pT = (j * 648) + (648 - T);
\r
752 ucCommand[pT + 7] = MaskT[ModuloT];
\r
754 for (i = (pB); i <= (pT); i++)
\r
756 ucCommand[i + 7] = 0x00;
\r
758 }//end of white part
\r
760 strcpy(ucCommand, "\033Db;o;2;");
\r
762 strncpy(&ucCommand[lCommandSize + 8], "\015", 1);
\r
764 info("Download varnish - statut : cover overlay");
\r
765 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
\r
766 if (numwritten != lCommandSize)
\r
768 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
\r
780 //=====================================================================
\r
781 // Convert color bitmap to monochrome bitmap
\r
782 //=====================================================================
\r
784 //////////////////////////////////////////////////////////////////////////////////////
\r
785 /////// RVB TO GRAY
\r
786 /////// Input parameters
\r
787 /////// lpMemIn : RVB data (3 byte by dot)
\r
788 /////// lNbrByte: number of byte to deal
\r
789 /////// Output parameter
\r
790 /////// lpMemOut: pointer on the gray data, result of the conversion
\r
793 //////////////////////////////////////////////////////////////////////////////////////
\r
795 void RVBtoGray(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte)
\r
799 unsigned char *lpbData, *lpbDataOut;
\r
800 unsigned char red, green, blue;
\r
803 //lpbData ppV mem bmp brute
\r
804 lpbData = &lpMemIn[0];
\r
805 lpbDataOut = &lpMemOut[0];
\r
806 // pour toutes les donnees
\r
807 while (lIndex < lNbrByte)
\r
809 blue = lpbData[(lIndex * 3)];
\r
810 green = lpbData[(lIndex * 3) + 1];
\r
811 red = lpbData[(lIndex * 3) + 2];
\r
812 d = RgbToGray(red, green, blue);
\r
813 lpbDataOut[lIndex] = (unsigned char) d;
\r
820 //////////////////////////////////////////////////////////////////////////////////////
\r
821 /////// GRAY THRESHOLD
\r
822 /////// Input parameters
\r
823 /////// lpMemIn : gray data (1 byte by dot)
\r
824 /////// lNbrByte: number of byte to deal
\r
828 /////// Output parameter
\r
829 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
\r
831 //////////////////////////////////////////////////////////////////////////////////////
\r
833 void GrayToThreshold(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte)
\r
836 unsigned char *lpbData, *lpbDataOut;
\r
839 //lpbData ppV mem bmp brute
\r
840 lpbData = &lpMemIn[0];
\r
841 lpbDataOut = &lpMemOut[0];
\r
842 // pour toutes les donnees
\r
843 while (lIndex < lNbrByte)
\r
847 gray = lpbData[lIndex];
\r
853 lpbDataOut[lIndex] = (unsigned char) gray;
\r
861 //////////////////////////////////////////////////////////////////////////////////////
\r
862 /////// GRAY DITHER
\r
863 /////// Input parameters
\r
864 /////// lpMemIn : gray data (1 byte by dot)
\r
865 /////// Height : height of the BMP image (648)
\r
866 /////// Width : width of the BMP image (1016)
\r
868 /////// Output parameter
\r
869 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
\r
870 //////////////////////////////////////////////////////////////////////////////////////
\r
872 void GrayToDither(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height)
\r
874 long index_line = 0, index_dot = 0;
\r
875 unsigned char *lpbData, *lpbDataOut;
\r
879 //lpbData ppV mem bmp brute
\r
880 lpbData = &lpMemIn[0];
\r
882 lpbDataOut = &lpMemOut[0];
\r
883 // pour toutes les donnees
\r
884 if (Height < Width)
\r
886 index_line = Width;
\r
888 Height = index_line;
\r
892 for (index_line = 0; index_line < Height; index_line++)
\r
894 for (index_dot = 0; index_dot < Width; index_dot++)
\r
896 gray = lpbData[index_dot + (index_line * Width)];
\r
898 if (k > DitherPattern1[index_line % 8][index_dot % 8])
\r
902 lpbDataOut[index_dot + (index_line * Width)] = (unsigned char) gray;
\r
908 //////////////////////////////////////////////////////////////////////////////////////
\r
910 /////// Input parameters
\r
911 /////// lpMemIn : gray data (1 byte by dot)
\r
912 /////// Height : height of the BMP image (648)
\r
913 /////// Width : width of the BMP image (1016)
\r
914 /////// Output parameter
\r
915 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
\r
916 //////////////////////////////////////////////////////////////////////////////////////
\r
918 void GrayToFloyd(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height)
\r
920 long index_line = 0, index_dot = 0;
\r
921 unsigned char *lpbData, *lpbDataOut;
\r
924 int NextError[1032];
\r
926 int CE3, CE5, CE7, CE1;
\r
928 if (Height < Width)
\r
930 index_line = Width;
\r
933 Height = index_line;
\r
937 for (index_line = 0; index_line < 1032; index_line++)
\r
939 Error[index_line] = NextError[index_line] = 0;
\r
941 //lpbData ppV mem bmp brute
\r
944 lpbData = &lpMemIn[0];
\r
945 lpbDataOut = &lpMemOut[0];
\r
946 // pour toutes les donnees
\r
947 for (index_line = 0; index_line < Height; index_line++)
\r
950 //for(index_dot = Width ; index_dot > 0; index_dot--)
\r
951 for (index_dot = 0; index_dot < Width; index_dot++)
\r
953 gray = lpbData[index_dot + (index_line * Width)];
\r
955 k = (gray + (int) Error[index_dot]);
\r
956 if (k > -128 && k < 128)
\r
963 lpbDataOut[index_dot + (index_line * Width)] = 0xFF - (unsigned char) l;
\r
968 CE3 = (Cerror * 3 / 16);
\r
969 CE5 = (Cerror * 5 / 16);
\r
970 CE7 = (Cerror * 7 / 16);
\r
971 CE1 = Cerror - CE3 - CE5 - CE7;
\r
973 NextError[index_dot] += CE5;
\r
974 if (index_dot < 1031)
\r
976 Error[index_dot + 1] += CE7;
\r
977 NextError[index_dot + 1] += CE1;
\r
980 NextError[index_dot - 1] += CE3;
\r
982 for (index_dot = 0; index_dot < 1032; index_dot++)
\r
984 Error[index_dot] = NextError[index_dot];
\r
985 NextError[index_dot] = 0;
\r
991 ////////////////////////////////////////////////////////////////////////////////////
\r
994 /////// Input parameters
\r
995 /////// lpbRVB : rvb color data from a 24 bits 1 panel BMP file
\r
996 /////// RVBSize : number of byte for the color data [(1016*648)]*3
\r
998 /////// Height : height of the BMP image (648)
\r
999 /////// Width : width of the BMP image (1016)
\r
1000 /////// Type : type of monochrome dealing (threshold, floyd or dither)
\r
1002 /////// Output parameter
\r
1004 /////// lpBlack : pointer on the monochrome data, result of the color conversion
\r
1005 //////////////////////////////////////////////////////////////////////////////////////
\r
1006 void ConvertRVBtoK(unsigned char *lpbRVB, long RVBSize, long Height, long Width, unsigned char *lpBlack)
\r
1008 //long y = 0,x = 0;
\r
1009 //long index_line = 0 , index_dot = 0;
\r
1011 if (!(strcmp(TreatementK, "GE")))// == NULL)
\r
1013 GrayToFloyd(lpbRVB, lpBlack, Width, Height);
\r
1015 else if (!(strcmp(TreatementK, "LM")))// == NULL)
\r
1017 GrayToThreshold(lpbRVB, lpBlack, (RVBSize / 5));
\r
1023 //========================================================//
\r
1024 // OPTION : Not real black printed
\r
1025 // Insert sublimable black from K panel to Y,M & C panels
\r
1026 //========================================================//
\r
1027 void KinYMC(long Height, long Width)
\r
1030 unsigned char *lpYellow, *lpMagenta, *lpCyan, *lpBlack;
\r
1033 dwSize = Width * Height;
\r
1034 lpYellow = &lpMem[0];
\r
1035 lpMagenta = &lpMem[dwSize];
\r
1036 lpCyan = &lpMem[2 * dwSize];
\r
1037 lpBlack = &lpMem[3 * dwSize];
\r
1038 for (i = 0; i < dwSize; i++)
\r
1042 lpYellow[i] |= lpBlack[i];
\r
1043 lpMagenta[i] |= lpBlack[i];
\r
1044 lpCyan[i] |= lpBlack[i];
\r
1049 //========================================================//
\r
1050 // OPTION : Get the first YMC printed dots
\r
1051 //========================================================//
\r
1052 void GetFirstYMCDot(long Height, long Width , int *x, int *y)
\r
1055 unsigned char *lpYellow, *lpMagenta, *lpCyan, *lpBlack;
\r
1058 dwSize = Width * Height;
\r
1059 lpYellow = &lpMem[0];
\r
1060 lpMagenta = &lpMem[dwSize];
\r
1061 lpCyan = &lpMem[2 * dwSize];
\r
1062 //for (i = 0; i < dwSize; i++)
\r
1063 while(i < dwSize && !fi)
\r
1065 if(lpYellow[i] || lpMagenta[i] || lpCyan[i] )
\r
1073 // End of "evolis.c,v 1.0 ".
\r