10 #include "evoliserror.h"
13 #define RgbToGray(r, g, b) (((long) (r)*74L + (long)(g)*155L +(long)(b)*27L) >> 8)
16 int STATUS=0; //0 means succes, 1 means failure
18 unsigned char *lpRecto,*lpVerso;
19 int Model; /* Model number */
20 long dwSizeNeeded; // taille mmoire du lpMem en octets
24 OverlayBackPannel[10],
27 int TB,LB,BB,RB,TW,LW,BW,RW;
29 int colorspace,levelB;
32 int DitherPattern1[8][8] = {
33 {0, 112, 28, 140, 7, 119, 35, 147},
34 {168, 56, 196, 84, 175, 63, 203, 78},
35 {42, 154, 14, 126, 49, 161, 21, 114},
36 {210, 98, 182, 70, 217, 105, 189, 77},
37 {11, 123, 39, 151, 4, 116, 32, 143},
38 {179, 67, 207, 95, 172, 59, 200, 88},
39 {53, 165, 24, 137, 46, 158, 18, 111},
40 {221, 109, 193, 81, 214, 102, 159, 74}
45 // Compress and format data for the printer
46 long ReduceBlack(unsigned char *lpMemIn, unsigned char *lpMemOut,int nbrline);
47 long ReduceColor(unsigned char *lpMemIn, unsigned char *lpMemOut, int uiBitComp);//,int nbrline);
48 //int CutPage(long *stop);
51 int DBNC(int col,int bl,int ov);//,int line);
52 int DB32NC(long lPos, char color); //y,m,c pannels 5 bits per color
53 int DB64NC(long lPos, char color); //y,m,c pannels 6 bits per color
54 int DB128NC(long lPos, char color); //y,m,c pannels 7 bits per color
55 /*int DB32NCS(long lPos, char color,int line); //y,m,c pannels 5 bits per color
56 int DB64NCS(long lPos, char color,int line); //y,m,c pannels 6 bits per color
57 int DB128NCS(long lPos, char color,int line); //y,m,c pannels 7 bits per color*/
58 int DB2NC(long lPos, char pannel[10]); // k,o panel 2 levels
59 int DB2MNC(long lPos); // k panel 2 levels
61 // Convert RVB to k functions
62 void RVBtoGray(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte);
63 void KinYMC(long Height, long Width);
64 void GrayToFloyd(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height);
65 void GrayToDither(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height);
66 void GrayToThreshold(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte);
67 void ConvertRVBtoK(unsigned char *lpbRVB, long RVBSize, long Height, long Width, unsigned char *lpBlack,int face);
68 void GetFirstYMCDot(long Height, long Width , int *x, int *y);
71 //===============================================================================//
72 // Reduce color data from 8 bits to uiBitComp.
74 // Entree : 1 color panel (1016 * 648 octets)
75 // Sortie : 1 color panel with usable data ((1016*648)*uiBitComp)/8
76 //===============================================================================//
79 long ReduceColor(unsigned char *lpMemIn, unsigned char *lpMemOut, int uiBitComp)//,int nbrline)
81 long lIndex = 0, lIndex1 = 0;
82 unsigned char *lpbBuf, *lpbData, *lpbDataOut;
84 long lNbrByte = (1016*648);
86 //Reservation mÔøΩoire pour traitement d'une ligne
93 //fprintf(stderr, "**************** EVOLIS ReduceColor manque de memoire pour lpBuf: taille demande 8 octets... \n");
94 fatal("ReduceColor Fails memory lpBuf: requested size 8 bytes...");
96 /// sortir de l'impression....
100 //lpbData ppV mem bmp brute
101 lpbData = &lpMemIn[0];
103 lpbDataOut = &lpMemOut[0];
104 // pour toutes les donnees
105 while (lIndex < lNbrByte)
108 for (lIndex1 = 0; lIndex1 < 8; lIndex1++)
110 if (lIndex < lNbrByte)
112 //decalage donnees utiles
113 lpbBuf[lIndex1] = *(lpbData++) >> (8 - uiBitComp);
119 lpbBuf[lIndex1] = 0x00;
126 *(lpbDataOut++) = (lpbBuf[0] << 2) | (lpbBuf[1] >> 4);
127 *(lpbDataOut++) = (lpbBuf[1] << 4) | (lpbBuf[2] >> 2);
128 *(lpbDataOut++) = (lpbBuf[2] << 6) | (lpbBuf[3]);
129 *(lpbDataOut++) = (lpbBuf[4] << 2) | (lpbBuf[5] >> 4);
130 *(lpbDataOut++) = (lpbBuf[5] << 4) | (lpbBuf[6] >> 2);
131 *(lpbDataOut++) = (lpbBuf[6] << 6) | (lpbBuf[7]);
134 *(lpbDataOut++) = (lpbBuf[0] << 1) | (lpbBuf[1] >> 6);
135 *(lpbDataOut++) = (lpbBuf[1] << 2) | (lpbBuf[2] >> 5);
136 *(lpbDataOut++) = (lpbBuf[2] << 3) | (lpbBuf[3] >> 4);
137 *(lpbDataOut++) = (lpbBuf[3] << 4) | (lpbBuf[4] >> 3);
139 *(lpbDataOut++) = (lpbBuf[4] << 5) | (lpbBuf[5] >> 2);
140 *(lpbDataOut++) = (lpbBuf[5] << 6) | (lpbBuf[6] >> 1);
141 *(lpbDataOut++) = (lpbBuf[6] << 7) | (lpbBuf[7]);
145 *(lpbDataOut++) = (lpbBuf[0] << 3) | (lpbBuf[1] >> 2);
146 *(lpbDataOut++) = (lpbBuf[1] << 6) | (lpbBuf[2] << 1) | (lpbBuf[3] >> 4);
147 *(lpbDataOut++) = (lpbBuf[3] << 4) | (lpbBuf[4] >> 1);
149 *(lpbDataOut++) = (lpbBuf[4] << 7) | (lpbBuf[5] << 2) | (lpbBuf[6] >> 3);
150 *(lpbDataOut++) = (lpbBuf[6] << 5) | (lpbBuf[7]);
155 lComp = (((lNbrByte * 10) / 8) * uiBitComp);
164 //===================================================//
165 // fonction pour le panneau noir & overlay uniquement
166 // entree : 1 octect = 1 points
167 // sortie : 1 octect = 8 points
171 //===================================================//
172 long ReduceBlack(unsigned char *lpMemIn, unsigned char *lpMemOut,int nbrline)
174 long lIndex = 0, lIndex1 = 0;
175 unsigned char *lpbData, *lpbDataOut;
177 unsigned char bBuf = 0x00;
179 unsigned char Mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
180 long lNbrByte = nbrline * 648;
183 //lpbData ppV mem bmp brute
184 lpbData = &lpMemIn[0];
185 lpbDataOut = &lpMemOut[0];
186 // pour toutes les donnees
188 while (lIndex < lNbrByte)
193 for (lIndex1 = 0; lIndex1 < 8; lIndex1++)
196 if (lIndex < lNbrByte)
198 if (*(lpbData++) == 0xFF)
200 bBuf |= Mask[lIndex1];
205 *(lpbDataOut++) = bBuf;
212 //=====================================================================
213 // Convert bitmap RVB data to evolis data format
214 //=====================================================================
217 int DBNC(int col,int bl,int ov)//,int line)
219 //output("\033Ss\015"); // debut sequence + CR
222 DB32NC(0 * (dwSizeNeeded / 5), 'y');
223 DB32NC(1 * (dwSizeNeeded / 5), 'm');
224 DB32NC(2 * (dwSizeNeeded / 5), 'c');
227 DB64NC(0 * (dwSizeNeeded / 5), 'y');
228 DB64NC(1 * (dwSizeNeeded / 5), 'm');
229 DB64NC(2 * (dwSizeNeeded / 5), 'c');
232 DB128NC(0 * (dwSizeNeeded / 5), 'y');
233 DB128NC(1 * (dwSizeNeeded / 5), 'm');
234 DB128NC(2 * (dwSizeNeeded / 5), 'c');
238 DB2NC(3 * (dwSizeNeeded / 5), "ABP");
242 if(ov == 1){//overlay at front
243 DB2NC(0, OverlayPannel);
246 DB2NC(0, OverlayBackPannel);
250 //output("\033Se\015....................................."); // fin sequence + CR
254 //===============================================================//
255 // Telechargement d'un panneau non compresse 5 bits
256 // Input : ucData / raw data
259 // -1 si erreur ecriture
260 //===============================================================//
261 int DB32NC(long lPos, char color)
263 unsigned char *ucCommand, *ucCol;
264 long lCommandSize = ((1016 * 648) * 5) / 8;
268 //Reservation memoire pour une commande de telechargement
269 ucCommand = malloc(lCommandSize + 12);
271 fatal("DP32NC Error: Fails malloc... ");
275 ucCol = &lpMem[lPos];
276 strcpy((char*) ucCommand, "\033Db;y;32;");
277 strncpy((char*) &ucCommand[4], &color, 1);
279 lComp = ReduceColor(ucCol, &ucCommand[9], 5);//,1016);
281 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
282 if (numwritten != lCommandSize) {
283 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
288 while(lComp > 4096) {
289 numwritten += fwrite(&ucCommand[numwritten], sizeof(unsigned char), 4096, stdout);
292 debug("NuwWritten %d", numwritten);
294 numwritten += fwrite(&ucCommand[numwritten], sizeof(unsigned char), lComp, stdout);
296 debug("lComp %d numwritten %d lCommandSize %d", lComp,numwritten,lCommandSize);
297 if (numwritten != lCommandSize) {
298 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
308 //===============================================================//
309 // Telechargement d'un panneau non compresse 6 bits
310 // Input : ucData / raw data
313 // -1 si erreur ecriture
314 //===============================================================//
316 int DB64NC(long lPos, char color)
318 unsigned char *ucCommand, *ucCol;
321 long lCommandSize = ((1016 * 648) * 6) / 8;
326 //Reservation memoire pour une commande de telechargement
327 ucCommand = malloc(lCommandSize + 10);
328 debug("DP64NC Size for one panel: %d... \n", (lCommandSize + 10));
333 fatal("DP64NC Error: Fails malloc...");
339 ucCol = &lpMem[lPos];
340 strcpy((char*) ucCommand, "\033Db;y;64;");
341 strncpy((char*) &ucCommand[4], &color, 1);
344 lComp = ReduceColor(ucCol, &ucCommand[9], 6);//,1016);
345 //fprintf(stderr, "**************** EVOLIS DP64NC taille apres compression %d... \n",lComp);
346 strncpy((char*)&ucCommand[lCommandSize + 9], "\015", 1);
348 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
349 if (numwritten != lCommandSize)
351 fatal("DP64NC Error: Fails fwrite %d... \n", numwritten);
363 //===============================================================//
364 // Telechargement d'un panneau non compresse 7 bits
365 // Input : ucData / raw data
368 // -1 si erreur ecriture
369 //===============================================================//
370 int DB128NC(long lPos, char color)
373 unsigned char *ucCommand, *ucCol;
374 long lCommandSize = ((1016 * 648) * 7) / 8;
378 //Reservation memoire pour une commande de telechargement
379 ucCommand = malloc(lCommandSize + 11);
380 debug("DP128NC Size for one panel: %d... ", (lCommandSize + 11));
383 fatal("DP128NC Error: Fails malloc... ");
388 ucCol = &lpMem[lPos];
389 strcpy((char*) ucCommand, "\033Db;y;128;");
390 strncpy((char*) &ucCommand[4], &color, 1);
391 lComp = ReduceColor(ucCol, &ucCommand[10], 7);//,1016);
392 strncpy((char*) &ucCommand[lCommandSize + 10], "\015", 1);
394 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
395 if (numwritten != lCommandSize)
397 fatal("DP128NC Error: Fails fwrite %d... \n", numwritten);
405 //===============================================================//
406 // Telechargement d'un panneau non compresse 5 bits YMCKOS
407 // Input : ucData / raw data
410 // -1 si erreur ecriture
411 //===============================================================//
412 /*int DB32NCS(long lPos, char color,int line)
414 unsigned char *ucCommand, *ucCol;
415 long lCommandSize = ((1016 * 648) * 5) / 8;
419 //Reservation memoire pour une commande de telechargement
420 ucCommand = malloc(lCommandSize + 20);
421 //fprintf(stderr, "**************** EVOLIS DP32NC Size for one panel: %d... \n", (lCommandSize+10));
424 //fprintf(stderr, "**************** EVOLIS DP32NC Error: Fails malloc... \n");
425 fatal("DP32NC Error: Fails malloc... ");
429 ucCol = &lpMem[lPos];
430 //strcpy(ucCommand, "\033Dbc;y;32;");
431 //nbroct = 540 * 648;
432 lCommandSize = ((520 * 648) * 5) / 8;
433 sprintf(ucCommand, "\033Dbc;y;32;%.4d;%.6d;",line,lCommandSize);
434 strncpy(&ucCommand[5], &color, 1);
436 info("%s",ucCommand);
437 lComp = ReduceColor(ucCol, &ucCommand[22], 5, 520);
438 strncpy(&ucCommand[lCommandSize + 22], "\015", 1);
441 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
442 //info("%d %s", numwritten,ucCommand);
443 if (numwritten != lCommandSize)
445 //fprintf(stderr, "**************** EVOLIS DP32NC Error: Fails printf %d... \n",numwritten);
446 fatal("DP32NC Error: Fails printf %d... \n", numwritten);
454 //===============================================================//
455 // Telechargement d'un panneau non compresse 6 bits YMCKOS
456 // Input : ucData / raw data
459 // -1 si erreur ecriture
460 //===============================================================//
462 int DB64NCS(long lPos, char color,int line)
464 unsigned char *ucCommand, *ucCol;
466 long lCommandSize = ((1016 * 648) * 6) / 8;
472 //Reservation memoire pour une commande de telechargement
473 ucCommand = malloc(lCommandSize + 10);
474 debug("DP64NC Size for one panel: %d... \n", (lCommandSize + 10));
479 fatal("DP64NC Error: Fails malloc...");
485 ucCol = &lpMem[lPos];
486 strcpy(ucCommand, "\033Db;y;64;");
487 strncpy(&ucCommand[4], &color, 1);
490 lComp = ReduceColor(ucCol, &ucCommand[9], 6, 540);
491 //fprintf(stderr, "**************** EVOLIS DP64NC taille apres compression %d... \n",lComp);
492 strncpy(&ucCommand[lCommandSize + 9], "\015", 1);
494 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
495 if (numwritten != lCommandSize)
497 fatal("DP64NC Error: Fails fwrite %d... \n", numwritten);
509 //===============================================================//
510 // Telechargement d'un panneau non compresse 7 bits YMCKOS
511 // Input : ucData / raw data
514 // -1 si erreur ecriture
515 //===============================================================//
516 int DB128NCS(long lPos, char color,int line)
519 unsigned char *ucCommand, *ucCol;
520 long lCommandSize = ((1016 * 648) * 7) / 8;
524 //Reservation memoire pour une commande de telechargement
525 ucCommand = malloc(lCommandSize + 11);
526 //fprintf(stderr, "**************** EVOLIS DP128NC Size for one panel: %d... \n", (lCommandSize+11));
527 debug("DP128NC Size for one panel: %d... ", (lCommandSize + 11));
532 fatal("DP128NC Error: Fails malloc... ");
537 ucCol = &lpMem[lPos];
538 strcpy(ucCommand, "\033Db;y;128;");
539 strncpy(&ucCommand[4], &color, 1);
540 lComp = ReduceColor(ucCol, &ucCommand[10], 7, 540);
541 //fprintf(stderr, "**************** EVOLIS DP128NC taille apres compression %d... \n",lComp);
542 strncpy(&ucCommand[lCommandSize + 10], "\015", 1);
544 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
545 if (numwritten != lCommandSize)
547 fatal("DP128NC Error: Fails fwrite %d... \n", numwritten);
555 //===============================================================//
556 // Telechargement d'un panneau non compresse overlay noir
557 // Input : ucData / raw datal978
561 // -1 si erreur ecriture
562 //===============================================================//
564 int DB2NC(long lPos, char pannel[10])
566 unsigned char *ucCommand, *ucCol;
569 long lCommandSize = ((1016 * 648)) / 8;
571 int B, T, L, R, i = 0, j = 0;
572 int pB, pT, ModuloB, ModuloT;
574 //unsigned char MaskB[8] = { 0x00,0x80,0xC0,0xE0,0xF0,0x7F,0x3F,0x1F};
575 //unsigned char MaskT[8] = { 0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F};
576 unsigned char MaskB[8] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
577 unsigned char MaskT[8] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
580 //Reservation memoire pour une commande de telechargement
582 ucCommand = malloc(lCommandSize + 9);
584 //debug("DP2NC Size for one panel: %d... ", (lCommandSize + 9));
589 fatal("DP2NC Error: Fails malloc... ");
594 if (!(strcmp(pannel, "ABP")))// == NULL)
596 ucCol = &lpMem[lPos];
597 strcpy((char*) ucCommand, "\033Db;k;2;");
598 lComp = ReduceBlack(ucCol, &ucCommand[8],1016);
599 strncpy((char*) &ucCommand[lCommandSize + 8], "\015", 1);
601 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
602 if (numwritten != lCommandSize)
604 fatal("DP2NC Error: Fails fprintf %d... ", numwritten);
610 else if (!(strcmp(pannel, "NO")))// == NULL)
612 memset(ucCommand, 0x00, lCommandSize);
613 strcpy((char*)ucCommand, "\033Db;o;2;");
614 strncpy((char*) &ucCommand[lCommandSize + 8], "\015", 1);
616 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
617 if (numwritten != lCommandSize)
619 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
624 else if (!(strcmp(pannel, "FO")))// == NULL)
626 memset(ucCommand, 0xFF, lCommandSize);
627 strcpy((char*) ucCommand, "\033Db;o;2;");
628 strncpy((char*) &ucCommand[lCommandSize + 8], "\015", 1);
630 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
631 if (numwritten != lCommandSize)
633 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
641 if (!(strcmp(pannel, "OA")))// == NULL)
648 debug("DP2NC OA... ");
649 memset(ucCommand, 0x00, lCommandSize);
652 for (j = L; j <= R; j++)
655 pB = (j * 648) + (648 - B);
660 ucCommand[pB + 7] = MaskB[ModuloB];
662 pT = (j * 648) + (648 - T);
667 ucCommand[pT + 7] = MaskT[ModuloT];
669 for (i = (pB); i <= (pT); i++)
671 ucCommand[i + 7] = 0xFF;
679 else if (!(strcmp(pannel, "SCI")))// == NULL)
686 memset(ucCommand, 0xFF, lCommandSize);
687 debug("DP2NC SCI... ");
689 else if (!(strcmp(pannel, "SCA")))// == NULL)
696 memset(ucCommand, 0xFF, lCommandSize);
697 debug("DP2NC SCA... ");
699 else if (!(strcmp(pannel, "MS")))// == NULL)
706 memset(ucCommand, 0xFF, lCommandSize);
707 debug("DP2NC MS... ");
710 for (j = L; j <= R; j++)
712 pB = (j * 648) + (648 - B);
717 ucCommand[pB + 7] = MaskB[ModuloB];
719 pT = (j * 648) + (648 - T);
724 ucCommand[pT + 7] = MaskT[ModuloT];
726 for (i = (pB); i <= (pT); i++)
728 ucCommand[i + 7] = 0x00;
732 strcpy((char*) ucCommand, "\033Db;o;2;");
734 strncpy((char*) &ucCommand[lCommandSize + 8], "\015", 1);
736 numwritten = fwrite(ucCommand, sizeof(unsigned char), lCommandSize, stdout);
737 if (numwritten != lCommandSize)
739 fatal("DP2NC Error: Fails fwrite %d... ", numwritten);
751 //=====================================================================
752 // Convert color bitmap to monochrome bitmap
753 //=====================================================================
755 //////////////////////////////////////////////////////////////////////////////////////
757 /////// Input parameters
758 /////// lpMemIn : RVB data (3 byte by dot)
759 /////// lNbrByte: number of byte to deal
760 /////// Output parameter
761 /////// lpMemOut: pointer on the gray data, result of the conversion
764 //////////////////////////////////////////////////////////////////////////////////////
766 void RVBtoGray(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte)
770 unsigned char *lpbData, *lpbDataOut;
771 unsigned char red, green, blue;
774 //lpbData ppV mem bmp brute
775 lpbData = &lpMemIn[0];
776 lpbDataOut = &lpMemOut[0];
777 // pour toutes les donnees
778 while (lIndex < lNbrByte)
780 blue = lpbData[(lIndex * 3)];
781 green = lpbData[(lIndex * 3) + 1];
782 red = lpbData[(lIndex * 3) + 2];
783 d = RgbToGray(red, green, blue);
784 lpbDataOut[lIndex] = (unsigned char) d;
791 //////////////////////////////////////////////////////////////////////////////////////
792 /////// GRAY THRESHOLD
793 /////// Input parameters
794 /////// lpMemIn : gray data (1 byte by dot)
795 /////// lNbrByte: number of byte to deal
799 /////// Output parameter
800 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
802 //////////////////////////////////////////////////////////////////////////////////////
804 void GrayToThreshold(unsigned char *lpMemIn, unsigned char *lpMemOut, long lNbrByte)
807 unsigned char *lpbData, *lpbDataOut;
810 //lpbData ppV mem bmp brute
811 lpbData = &lpMemIn[0];
812 lpbDataOut = &lpMemOut[0];
813 // pour toutes les donnees
814 while (lIndex < lNbrByte)
818 gray = lpbData[lIndex];
824 lpbDataOut[lIndex] = (unsigned char) gray;
832 //////////////////////////////////////////////////////////////////////////////////////
834 /////// Input parameters
835 /////// lpMemIn : gray data (1 byte by dot)
836 /////// Height : height of the BMP image (648)
837 /////// Width : width of the BMP image (1016)
839 /////// Output parameter
840 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
841 //////////////////////////////////////////////////////////////////////////////////////
843 void GrayToDither(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height)
845 long index_line = 0, index_dot = 0;
846 unsigned char *lpbData, *lpbDataOut;
850 //lpbData ppV mem bmp brute
851 lpbData = &lpMemIn[0];
853 lpbDataOut = &lpMemOut[0];
854 // pour toutes les donnees
863 for (index_line = 0; index_line < Height; index_line++)
865 for (index_dot = 0; index_dot < Width; index_dot++)
867 gray = lpbData[index_dot + (index_line * Width)];
869 if (k > DitherPattern1[index_line % 8][index_dot % 8])
873 lpbDataOut[index_dot + (index_line * Width)] = (unsigned char) gray;
879 //////////////////////////////////////////////////////////////////////////////////////
881 /////// Input parameters
882 /////// lpMemIn : gray data (1 byte by dot)
883 /////// Height : height of the BMP image (648)
884 /////// Width : width of the BMP image (1016)
885 /////// Output parameter
886 /////// lpMemOut: pointer on the monochrome data, result of the gray conversion
887 //////////////////////////////////////////////////////////////////////////////////////
889 void GrayToFloyd(unsigned char *lpMemIn, unsigned char *lpMemOut, long Width, long Height)
891 long index_line = 0, index_dot = 0;
892 unsigned char *lpbData, *lpbDataOut;
897 int CE3, CE5, CE7, CE1;
908 for (index_line = 0; index_line < 1032; index_line++)
910 Error[index_line] = NextError[index_line] = 0;
912 //lpbData ppV mem bmp brute
915 lpbData = &lpMemIn[0];
916 lpbDataOut = &lpMemOut[0];
917 // pour toutes les donnees
918 for (index_line = 0; index_line < Height; index_line++)
921 //for(index_dot = Width ; index_dot > 0; index_dot--)
922 for (index_dot = 0; index_dot < Width; index_dot++)
924 gray = lpbData[index_dot + (index_line * Width)];
926 k = (gray + (int) Error[index_dot]);
927 if (k > -128 && k < 128)
934 lpbDataOut[index_dot + (index_line * Width)] = 0xFF - (unsigned char) l;
939 CE3 = (Cerror * 3 / 16);
940 CE5 = (Cerror * 5 / 16);
941 CE7 = (Cerror * 7 / 16);
942 CE1 = Cerror - CE3 - CE5 - CE7;
944 NextError[index_dot] += CE5;
945 if (index_dot < 1031)
947 Error[index_dot + 1] += CE7;
948 NextError[index_dot + 1] += CE1;
951 NextError[index_dot - 1] += CE3;
953 for (index_dot = 0; index_dot < 1032; index_dot++)
955 Error[index_dot] = NextError[index_dot];
956 NextError[index_dot] = 0;
962 ////////////////////////////////////////////////////////////////////////////////////
965 /////// Input parameters
966 /////// lpbRVB : rvb color data from a 24 bits 1 panel BMP file
967 /////// RVBSize : number of byte for the color data [(1016*648)]*3
969 /////// Height : height of the BMP image (648)
970 /////// Width : width of the BMP image (1016)
971 /////// Type : type of monochrome dealing (threshold, floyd or dither)
972 /////// face : RECTO / VERSO
974 /////// Output parameter
976 /////// lpBlack : pointer on the monochrome data, result of the color conversion
977 //////////////////////////////////////////////////////////////////////////////////////
978 void ConvertRVBtoK(unsigned char *lpbRVB, long RVBSize, long Height, long Width, unsigned char *lpBlack, int face)
980 if ( toupper(TreatementK[face]) =='G' ) // Grey Mode
982 GrayToFloyd(lpbRVB, lpBlack, Width, Height);
986 GrayToThreshold(lpbRVB, lpBlack, (RVBSize / 5));
990 //========================================================//
991 // OPTION : Not real black printed
992 // Insert sublimable black from K panel to Y,M & C panels
993 //========================================================//
994 void KinYMC(long Height, long Width)
997 unsigned char *lpYellow, *lpMagenta, *lpCyan, *lpBlack;
1000 dwSize = Width * Height;
1001 lpYellow = &lpMem[0];
1002 lpMagenta = &lpMem[dwSize];
1003 lpCyan = &lpMem[2 * dwSize];
1004 lpBlack = &lpMem[3 * dwSize];
1005 for (i = 0; i < dwSize; i++)
1009 lpYellow[i] |= lpBlack[i];
1010 lpMagenta[i] |= lpBlack[i];
1011 lpCyan[i] |= lpBlack[i];
1016 //========================================================//
1017 // OPTION : Get the first YMC printed dots
1018 //========================================================//
1019 void GetFirstYMCDot(long Height, long Width , int *x, int *y)
1022 unsigned char *lpYellow, *lpMagenta, *lpCyan, *lpBlack;
1025 dwSize = Width * Height;
1026 lpYellow = &lpMem[0];
1027 lpMagenta = &lpMem[dwSize];
1028 lpCyan = &lpMem[2 * dwSize];
1029 //for (i = 0; i < dwSize; i++)
1030 while(i < dwSize && !fi)
1032 if(lpYellow[i] || lpMagenta[i] || lpCyan[i] )
1040 // End of "evolis.c,v 1.0 ".