]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/cmyk.c
4 * CMYK color separation code for CUPS.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1993-2005 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsCMYKDelete() - Delete a color separation.
18 * cupsCMYKDoBlack() - Do a black separation...
19 * cupsCMYKDoCMYK() - Do a CMYK separation...
20 * cupsCMYKDoGray() - Do a grayscale separation...
21 * cupsCMYKDoRGB() - Do an sRGB separation...
22 * cupsCMYKLoad() - Load a CMYK color profile from PPD attributes.
23 * cupsCMYKNew() - Create a new CMYK color separation.
24 * cupsCMYKSetBlack() - Set the transition range for CMY to black.
25 * cupsCMYKSetCurve() - Set a color transform curve using points.
26 * cupsCMYKSetGamma() - Set a color transform curve using gamma and
28 * cupsCMYKSetInkLimit() - Set the limit on the amount of ink.
29 * cupsCMYKSetLtDk() - Set light/dark ink transforms.
33 * Include necessary headers.
37 #include <cups/string-private.h>
41 * 'cupsCMYKDelete()' - Delete a color separation.
45 cupsCMYKDelete(cups_cmyk_t
*cmyk
) /* I - Color separation */
48 * Range check input...
58 free(cmyk
->channels
[0]);
64 * 'cupsCMYKDoBlack()' - Do a black separation...
68 cupsCMYKDoBlack(const cups_cmyk_t
*cmyk
,
69 /* I - Color separation */
70 const unsigned char *input
,
71 /* I - Input grayscale pixels */
73 /* O - Output Device-N pixels */
75 /* I - Number of pixels */
77 int k
; /* Current black value */
78 const short **channels
; /* Copy of channel LUTs */
79 int ink
, /* Amount of ink */
80 ink_limit
; /* Ink limit from separation */
84 * Range check input...
87 if (cmyk
== NULL
|| input
== NULL
|| output
== NULL
|| num_pixels
<= 0)
91 * Loop through it all...
94 channels
= (const short **)cmyk
->channels
;
95 ink_limit
= cmyk
->ink_limit
;
97 switch (cmyk
->num_channels
)
100 while (num_pixels
> 0)
103 * Get the input black value and then set the corresponding color
108 *output
++ = channels
[0][k
];
114 case 2 : /* Black, light black */
115 while (num_pixels
> 0)
118 * Get the input black value and then set the corresponding color
123 output
[0] = channels
[0][k
];
124 output
[1] = channels
[1][k
];
128 ink
= output
[0] + output
[1];
132 output
[0] = ink_limit
* output
[0] / ink
;
133 output
[1] = ink_limit
* output
[1] / ink
;
143 while (num_pixels
> 0)
146 * Get the input black value and then set the corresponding color
151 output
[0] = channels
[0][k
];
152 output
[1] = channels
[1][k
];
153 output
[2] = channels
[2][k
];
157 ink
= output
[0] + output
[1] + output
[2];
161 output
[0] = ink_limit
* output
[0] / ink
;
162 output
[1] = ink_limit
* output
[1] / ink
;
163 output
[2] = ink_limit
* output
[2] / ink
;
173 while (num_pixels
> 0)
176 * Get the input black value and then set the corresponding color
184 *output
++ = channels
[3][k
];
190 case 6 : /* CcMmYK */
191 while (num_pixels
> 0)
194 * Get the input black value and then set the corresponding color
204 *output
++ = channels
[5][k
];
210 case 7 : /* CcMmYKk */
211 while (num_pixels
> 0)
214 * Get the input black value and then set the corresponding color
224 output
[5] = channels
[5][k
];
225 output
[6] = channels
[6][k
];
229 ink
= output
[5] + output
[6];
233 output
[5] = ink_limit
* output
[5] / ink
;
234 output
[6] = ink_limit
* output
[6] / ink
;
247 * 'cupsCMYKDoCMYK()' - Do a CMYK separation...
251 cupsCMYKDoCMYK(const cups_cmyk_t
*cmyk
,
252 /* I - Color separation */
253 const unsigned char *input
,
254 /* I - Input grayscale pixels */
256 /* O - Output Device-N pixels */
258 /* I - Number of pixels */
260 int c
, /* Current cyan value */
261 m
, /* Current magenta value */
262 y
, /* Current yellow value */
263 k
; /* Current black value */
264 const short **channels
; /* Copy of channel LUTs */
265 int ink
, /* Amount of ink */
266 ink_limit
; /* Ink limit from separation */
270 * Range check input...
273 if (cmyk
== NULL
|| input
== NULL
|| output
== NULL
|| num_pixels
<= 0)
277 * Loop through it all...
280 channels
= (const short **)cmyk
->channels
;
281 ink_limit
= cmyk
->ink_limit
;
283 switch (cmyk
->num_channels
)
286 while (num_pixels
> 0)
289 * Get the input black value and then set the corresponding color
296 k
= *input
++ + (c
* 31 + m
* 61 + y
* 8) / 100;
299 *output
++ = channels
[0][k
];
301 *output
++ = channels
[0][255];
307 case 2 : /* Black, light black */
308 while (num_pixels
> 0)
311 * Get the input black value and then set the corresponding color
318 k
= *input
++ + (c
* 31 + m
* 61 + y
* 8) / 100;
322 output
[0] = channels
[0][k
];
323 output
[1] = channels
[1][k
];
327 output
[0] = channels
[0][255];
328 output
[1] = channels
[1][255];
333 ink
= output
[0] + output
[1];
337 output
[0] = ink_limit
* output
[0] / ink
;
338 output
[1] = ink_limit
* output
[1] / ink
;
348 while (num_pixels
> 0)
351 * Get the input black value and then set the corresponding color
364 output
[0] = channels
[0][c
];
366 output
[0] = channels
[0][255];
369 output
[1] = channels
[1][m
];
371 output
[1] = channels
[1][255];
374 output
[2] = channels
[2][y
];
376 output
[2] = channels
[2][255];
380 ink
= output
[0] + output
[1] + output
[2];
384 output
[0] = ink_limit
* output
[0] / ink
;
385 output
[1] = ink_limit
* output
[1] / ink
;
386 output
[2] = ink_limit
* output
[2] / ink
;
396 while (num_pixels
> 0)
399 * Get the input black value and then set the corresponding color
408 output
[0] = channels
[0][c
];
409 output
[1] = channels
[1][m
];
410 output
[2] = channels
[2][y
];
411 output
[3] = channels
[3][k
];
415 ink
= output
[0] + output
[1] + output
[2] + output
[3];
419 output
[0] = ink_limit
* output
[0] / ink
;
420 output
[1] = ink_limit
* output
[1] / ink
;
421 output
[2] = ink_limit
* output
[2] / ink
;
422 output
[3] = ink_limit
* output
[3] / ink
;
431 case 6 : /* CcMmYK */
432 while (num_pixels
> 0)
435 * Get the input black value and then set the corresponding color
444 output
[0] = channels
[0][c
];
445 output
[1] = channels
[1][c
];
446 output
[2] = channels
[2][m
];
447 output
[3] = channels
[3][m
];
448 output
[4] = channels
[4][y
];
449 output
[5] = channels
[5][k
];
453 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
454 output
[4] + output
[5];
458 output
[0] = ink_limit
* output
[0] / ink
;
459 output
[1] = ink_limit
* output
[1] / ink
;
460 output
[2] = ink_limit
* output
[2] / ink
;
461 output
[3] = ink_limit
* output
[3] / ink
;
462 output
[4] = ink_limit
* output
[4] / ink
;
463 output
[5] = ink_limit
* output
[5] / ink
;
472 case 7 : /* CcMmYKk */
473 while (num_pixels
> 0)
476 * Get the input black value and then set the corresponding color
485 output
[0] = channels
[0][c
];
486 output
[1] = channels
[1][c
];
487 output
[2] = channels
[2][m
];
488 output
[3] = channels
[3][m
];
489 output
[4] = channels
[4][y
];
490 output
[5] = channels
[5][k
];
491 output
[6] = channels
[6][k
];
495 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
496 output
[4] + output
[5] + output
[6];
500 output
[0] = ink_limit
* output
[0] / ink
;
501 output
[1] = ink_limit
* output
[1] / ink
;
502 output
[2] = ink_limit
* output
[2] / ink
;
503 output
[3] = ink_limit
* output
[3] / ink
;
504 output
[4] = ink_limit
* output
[4] / ink
;
505 output
[5] = ink_limit
* output
[5] / ink
;
506 output
[6] = ink_limit
* output
[6] / ink
;
519 * 'cupsCMYKDoGray()' - Do a grayscale separation...
523 cupsCMYKDoGray(const cups_cmyk_t
*cmyk
,
524 /* I - Color separation */
525 const unsigned char *input
,
526 /* I - Input grayscale pixels */
528 /* O - Output Device-N pixels */
530 /* I - Number of pixels */
532 int k
, /* Current black value */
533 kc
; /* Current black color value */
534 const short **channels
; /* Copy of channel LUTs */
535 int ink
, /* Amount of ink */
536 ink_limit
; /* Ink limit from separation */
540 * Range check input...
543 if (cmyk
== NULL
|| input
== NULL
|| output
== NULL
|| num_pixels
<= 0)
547 * Loop through it all...
550 channels
= (const short **)cmyk
->channels
;
551 ink_limit
= cmyk
->ink_limit
;
553 switch (cmyk
->num_channels
)
556 while (num_pixels
> 0)
559 * Get the input black value and then set the corresponding color
563 k
= cups_scmy_lut
[*input
++];
564 *output
++ = channels
[0][k
];
570 case 2 : /* Black, light black */
571 while (num_pixels
> 0)
574 * Get the input black value and then set the corresponding color
578 k
= cups_scmy_lut
[*input
++];
579 output
[0] = channels
[0][k
];
580 output
[1] = channels
[1][k
];
584 ink
= output
[0] + output
[1];
588 output
[0] = ink_limit
* output
[0] / ink
;
589 output
[1] = ink_limit
* output
[1] / ink
;
599 while (num_pixels
> 0)
602 * Get the input black value and then set the corresponding color
606 k
= cups_scmy_lut
[*input
++];
607 output
[0] = channels
[0][k
];
608 output
[1] = channels
[1][k
];
609 output
[2] = channels
[2][k
];
613 ink
= output
[0] + output
[1] + output
[2];
617 output
[0] = ink_limit
* output
[0] / ink
;
618 output
[1] = ink_limit
* output
[1] / ink
;
619 output
[2] = ink_limit
* output
[2] / ink
;
629 while (num_pixels
> 0)
632 * Get the input black value and then set the corresponding color
636 k
= cups_scmy_lut
[*input
++];
637 kc
= cmyk
->color_lut
[k
];
638 k
= cmyk
->black_lut
[k
];
639 output
[0] = channels
[0][kc
];
640 output
[1] = channels
[1][kc
];
641 output
[2] = channels
[2][kc
];
642 output
[3] = channels
[3][k
];
646 ink
= output
[0] + output
[1] + output
[2] + output
[3];
650 output
[0] = ink_limit
* output
[0] / ink
;
651 output
[1] = ink_limit
* output
[1] / ink
;
652 output
[2] = ink_limit
* output
[2] / ink
;
653 output
[3] = ink_limit
* output
[3] / ink
;
662 case 6 : /* CcMmYK */
663 while (num_pixels
> 0)
666 * Get the input black value and then set the corresponding color
670 k
= cups_scmy_lut
[*input
++];
671 kc
= cmyk
->color_lut
[k
];
672 k
= cmyk
->black_lut
[k
];
673 output
[0] = channels
[0][kc
];
674 output
[1] = channels
[1][kc
];
675 output
[2] = channels
[2][kc
];
676 output
[3] = channels
[3][kc
];
677 output
[4] = channels
[4][kc
];
678 output
[5] = channels
[5][k
];
682 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
683 output
[4] + output
[5];
687 output
[0] = ink_limit
* output
[0] / ink
;
688 output
[1] = ink_limit
* output
[1] / ink
;
689 output
[2] = ink_limit
* output
[2] / ink
;
690 output
[3] = ink_limit
* output
[3] / ink
;
691 output
[4] = ink_limit
* output
[4] / ink
;
692 output
[5] = ink_limit
* output
[5] / ink
;
701 case 7 : /* CcMmYKk */
702 while (num_pixels
> 0)
705 * Get the input black value and then set the corresponding color
709 k
= cups_scmy_lut
[*input
++];
710 kc
= cmyk
->color_lut
[k
];
711 k
= cmyk
->black_lut
[k
];
712 output
[0] = channels
[0][kc
];
713 output
[1] = channels
[1][kc
];
714 output
[2] = channels
[2][kc
];
715 output
[3] = channels
[3][kc
];
716 output
[4] = channels
[4][kc
];
717 output
[5] = channels
[5][k
];
718 output
[6] = channels
[6][k
];
722 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
723 output
[4] + output
[5] + output
[6];
727 output
[0] = ink_limit
* output
[0] / ink
;
728 output
[1] = ink_limit
* output
[1] / ink
;
729 output
[2] = ink_limit
* output
[2] / ink
;
730 output
[3] = ink_limit
* output
[3] / ink
;
731 output
[4] = ink_limit
* output
[4] / ink
;
732 output
[5] = ink_limit
* output
[5] / ink
;
733 output
[6] = ink_limit
* output
[6] / ink
;
746 * 'cupsCMYKDoRGB()' - Do an sRGB separation...
750 cupsCMYKDoRGB(const cups_cmyk_t
*cmyk
,
751 /* I - Color separation */
752 const unsigned char *input
,
753 /* I - Input grayscale pixels */
755 /* O - Output Device-N pixels */
757 /* I - Number of pixels */
759 int c
, /* Current cyan value */
760 m
, /* Current magenta value */
761 y
, /* Current yellow value */
762 k
, /* Current black value */
763 kc
, /* Current black color value */
764 km
; /* Maximum black value */
765 const short **channels
; /* Copy of channel LUTs */
766 int ink
, /* Amount of ink */
767 ink_limit
; /* Ink limit from separation */
771 * Range check input...
774 if (cmyk
== NULL
|| input
== NULL
|| output
== NULL
|| num_pixels
<= 0)
778 * Loop through it all...
781 channels
= (const short **)cmyk
->channels
;
782 ink_limit
= cmyk
->ink_limit
;
784 switch (cmyk
->num_channels
)
787 while (num_pixels
> 0)
790 * Get the input black value and then set the corresponding color
794 c
= cups_scmy_lut
[*input
++];
795 m
= cups_scmy_lut
[*input
++];
796 y
= cups_scmy_lut
[*input
++];
797 k
= (c
* 31 + m
* 61 + y
* 8) / 100;
799 *output
++ = channels
[0][k
];
805 case 2 : /* Black, light black */
806 while (num_pixels
> 0)
809 * Get the input black value and then set the corresponding color
813 c
= cups_scmy_lut
[*input
++];
814 m
= cups_scmy_lut
[*input
++];
815 y
= cups_scmy_lut
[*input
++];
816 k
= (c
* 31 + m
* 61 + y
* 8) / 100;
818 output
[0] = channels
[0][k
];
819 output
[1] = channels
[1][k
];
823 ink
= output
[0] + output
[1];
827 output
[0] = ink_limit
* output
[0] / ink
;
828 output
[1] = ink_limit
* output
[1] / ink
;
838 while (num_pixels
> 0)
841 * Get the input black value and then set the corresponding color
845 c
= cups_scmy_lut
[*input
++];
846 m
= cups_scmy_lut
[*input
++];
847 y
= cups_scmy_lut
[*input
++];
849 output
[0] = channels
[0][c
];
850 output
[1] = channels
[1][m
];
851 output
[2] = channels
[2][y
];
855 ink
= output
[0] + output
[1] + output
[2];
859 output
[0] = ink_limit
* output
[0] / ink
;
860 output
[1] = ink_limit
* output
[1] / ink
;
861 output
[2] = ink_limit
* output
[2] / ink
;
871 while (num_pixels
> 0)
874 * Get the input black value and then set the corresponding color
878 c
= cups_scmy_lut
[*input
++];
879 m
= cups_scmy_lut
[*input
++];
880 y
= cups_scmy_lut
[*input
++];
881 k
= min(c
, min(m
, y
));
883 if ((km
= max(c
, max(m
, y
))) > k
)
884 k
= k
* k
* k
/ (km
* km
);
886 kc
= cmyk
->color_lut
[k
] - k
;
887 k
= cmyk
->black_lut
[k
];
892 output
[0] = channels
[0][c
];
893 output
[1] = channels
[1][m
];
894 output
[2] = channels
[2][y
];
895 output
[3] = channels
[3][k
];
899 ink
= output
[0] + output
[1] + output
[2] + output
[3];
903 output
[0] = ink_limit
* output
[0] / ink
;
904 output
[1] = ink_limit
* output
[1] / ink
;
905 output
[2] = ink_limit
* output
[2] / ink
;
906 output
[3] = ink_limit
* output
[3] / ink
;
915 case 6 : /* CcMmYK */
916 while (num_pixels
> 0)
919 * Get the input black value and then set the corresponding color
923 c
= cups_scmy_lut
[*input
++];
924 m
= cups_scmy_lut
[*input
++];
925 y
= cups_scmy_lut
[*input
++];
926 k
= min(c
, min(m
, y
));
928 if ((km
= max(c
, max(m
, y
))) > k
)
929 k
= k
* k
* k
/ (km
* km
);
931 kc
= cmyk
->color_lut
[k
] - k
;
932 k
= cmyk
->black_lut
[k
];
937 output
[0] = channels
[0][c
];
938 output
[1] = channels
[1][c
];
939 output
[2] = channels
[2][m
];
940 output
[3] = channels
[3][m
];
941 output
[4] = channels
[4][y
];
942 output
[5] = channels
[5][k
];
946 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
947 output
[4] + output
[5];
951 output
[0] = ink_limit
* output
[0] / ink
;
952 output
[1] = ink_limit
* output
[1] / ink
;
953 output
[2] = ink_limit
* output
[2] / ink
;
954 output
[3] = ink_limit
* output
[3] / ink
;
955 output
[4] = ink_limit
* output
[4] / ink
;
956 output
[5] = ink_limit
* output
[5] / ink
;
965 case 7 : /* CcMmYKk */
966 while (num_pixels
> 0)
969 * Get the input black value and then set the corresponding color
973 c
= cups_scmy_lut
[*input
++];
974 m
= cups_scmy_lut
[*input
++];
975 y
= cups_scmy_lut
[*input
++];
976 k
= min(c
, min(m
, y
));
978 if ((km
= max(c
, max(m
, y
))) > k
)
979 k
= k
* k
* k
/ (km
* km
);
981 kc
= cmyk
->color_lut
[k
] - k
;
982 k
= cmyk
->black_lut
[k
];
987 output
[0] = channels
[0][c
];
988 output
[1] = channels
[1][c
];
989 output
[2] = channels
[2][m
];
990 output
[3] = channels
[3][m
];
991 output
[4] = channels
[4][y
];
992 output
[5] = channels
[5][k
];
993 output
[6] = channels
[6][k
];
997 ink
= output
[0] + output
[1] + output
[2] + output
[3] +
998 output
[4] + output
[5] + output
[6];
1000 if (ink
> ink_limit
)
1002 output
[0] = ink_limit
* output
[0] / ink
;
1003 output
[1] = ink_limit
* output
[1] / ink
;
1004 output
[2] = ink_limit
* output
[2] / ink
;
1005 output
[3] = ink_limit
* output
[3] / ink
;
1006 output
[4] = ink_limit
* output
[4] / ink
;
1007 output
[5] = ink_limit
* output
[5] / ink
;
1008 output
[6] = ink_limit
* output
[6] / ink
;
1021 * 'cupsCMYKLoad()' - Load a CMYK color profile from PPD attributes.
1024 cups_cmyk_t
* /* O - CMYK color separation */
1025 cupsCMYKLoad(ppd_file_t
*ppd
, /* I - PPD file */
1026 const char *colormodel
, /* I - ColorModel value */
1027 const char *media
, /* I - MediaType value */
1028 const char *resolution
) /* I - Resolution value */
1030 cups_cmyk_t
*cmyk
; /* CMYK color separation */
1031 char spec
[PPD_MAX_NAME
]; /* Profile name */
1032 ppd_attr_t
*attr
; /* Attribute from PPD file */
1033 int num_channels
; /* Number of color components */
1034 float gamval
, /* Gamma correction value */
1035 density
, /* Density value */
1036 light
, /* Light ink limit */
1037 dark
, /* Light ink cut-off */
1038 lower
, /* Start of black ink */
1039 upper
; /* End of color ink */
1040 int num_xypoints
; /* Number of X,Y points */
1041 float xypoints
[100 * 2], /* X,Y points */
1042 *xyptr
; /* Current X,Y point */
1046 * Range check input...
1049 if (ppd
== NULL
|| colormodel
== NULL
|| resolution
== NULL
|| media
== NULL
)
1053 * Find the following attributes:
1055 * cupsAllGamma - Set default curve using gamma + density
1056 * cupsAllXY - Set default curve using XY points
1057 * cupsBlackGamma - Set black curve using gamma + density
1058 * cupsBlackGeneration - Set black generation
1059 * cupsBlackLightDark - Set black light/dark transition
1060 * cupsBlackXY - Set black curve using XY points
1061 * cupsCyanGamma - Set cyan curve using gamma + density
1062 * cupsCyanLightDark - Set cyan light/dark transition
1063 * cupsCyanXY - Set cyan curve using XY points
1064 * cupsInkChannels - Set number of color channels
1065 * cupsInkLimit - Set total ink limit
1066 * cupsLightBlackGamma - Set light black curve using gamma + density
1067 * cupsLightBlackXY - Set light black curve using XY points
1068 * cupsLightCyanGamma - Set light cyan curve using gamma + density
1069 * cupsLightCyanXY - Set light cyan curve using XY points
1070 * cupsLightMagentaGamma - Set light magenta curve using gamma + density
1071 * cupsLightMagentaXY - Set light magenta curve using XY points
1072 * cupsMagentaGamma - Set magenta curve using gamma + density
1073 * cupsMagentaLightDark - Set magenta light/dark transition
1074 * cupsMagentaXY - Set magenta curve using XY points
1075 * cupsYellowGamma - Set yellow curve using gamma + density
1076 * cupsYellowXY - Set yellow curve using XY points
1078 * The only required attribute is cupsInkChannels.
1080 * The *XY attributes have precedence over the *Gamma attributes, and
1081 * the *Light* attributes have precedence over the corresponding
1082 * *LightDark* attributes.
1086 * Get the required cupsInkChannels attribute...
1089 if ((attr
= cupsFindAttr(ppd
, "cupsInkChannels", colormodel
, media
,
1090 resolution
, spec
, sizeof(spec
))) == NULL
)
1093 num_channels
= atoi(attr
->value
);
1095 if (num_channels
< 1 || num_channels
> 7 || num_channels
== 5)
1098 if ((cmyk
= cupsCMYKNew(num_channels
)) == NULL
)
1102 * Get the optional cupsInkLimit attribute...
1105 if ((attr
= cupsFindAttr(ppd
, "cupsInkLimit", colormodel
, media
,
1106 resolution
, spec
, sizeof(spec
))) != NULL
)
1107 cupsCMYKSetInkLimit(cmyk
, atof(attr
->value
));
1110 * Get the optional cupsBlackGeneration attribute...
1113 if ((attr
= cupsFindAttr(ppd
, "cupsBlackGeneration", colormodel
, media
,
1114 resolution
, spec
, sizeof(spec
))) != NULL
)
1116 if (sscanf(attr
->value
, "%f%f", &lower
, &upper
) == 2)
1117 cupsCMYKSetBlack(cmyk
, lower
, upper
);
1121 * Get the optional cupsBlackXY or cupsBlackGamma attributes...
1124 if (num_channels
!= 3)
1126 if ((attr
= cupsFindAttr(ppd
, "cupsBlackXY", colormodel
, media
,
1127 resolution
, spec
, sizeof(spec
))) != NULL
)
1129 for (num_xypoints
= 0, xyptr
= xypoints
;
1130 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1131 attr
= ppdFindNextAttr(ppd
, "cupsBlackXY", spec
))
1132 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1138 switch (num_channels
)
1142 cupsCMYKSetCurve(cmyk
, 0, num_xypoints
, xypoints
);
1145 cupsCMYKSetCurve(cmyk
, 3, num_xypoints
, xypoints
);
1149 cupsCMYKSetCurve(cmyk
, 5, num_xypoints
, xypoints
);
1153 else if ((attr
= cupsFindAttr(ppd
, "cupsBlackGamma", colormodel
,
1154 media
, resolution
, spec
,
1155 sizeof(spec
))) != NULL
)
1157 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1158 switch (num_channels
)
1162 cupsCMYKSetGamma(cmyk
, 0, gamval
, density
);
1165 cupsCMYKSetGamma(cmyk
, 3, gamval
, density
);
1169 cupsCMYKSetGamma(cmyk
, 5, gamval
, density
);
1173 else if ((attr
= cupsFindAttr(ppd
, "cupsAllXY", colormodel
, media
,
1174 resolution
, spec
, sizeof(spec
))) != NULL
)
1176 for (num_xypoints
= 0, xyptr
= xypoints
;
1177 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1178 attr
= ppdFindNextAttr(ppd
, "cupsAllXY", spec
))
1179 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1185 switch (num_channels
)
1189 cupsCMYKSetCurve(cmyk
, 0, num_xypoints
, xypoints
);
1192 cupsCMYKSetCurve(cmyk
, 3, num_xypoints
, xypoints
);
1196 cupsCMYKSetCurve(cmyk
, 5, num_xypoints
, xypoints
);
1200 else if ((attr
= cupsFindAttr(ppd
, "cupsAllGamma", colormodel
,
1201 media
, resolution
, spec
,
1202 sizeof(spec
))) != NULL
&&
1205 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1206 switch (num_channels
)
1210 cupsCMYKSetGamma(cmyk
, 0, gamval
, density
);
1213 cupsCMYKSetGamma(cmyk
, 3, gamval
, density
);
1217 cupsCMYKSetGamma(cmyk
, 5, gamval
, density
);
1223 if (num_channels
> 2)
1226 * Get the optional cupsCyanXY or cupsCyanGamma attributes...
1229 if ((attr
= cupsFindAttr(ppd
, "cupsCyanXY", colormodel
, media
,
1230 resolution
, spec
, sizeof(spec
))) != NULL
)
1232 for (num_xypoints
= 0, xyptr
= xypoints
;
1233 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1234 attr
= ppdFindNextAttr(ppd
, "cupsCyanXY", spec
))
1235 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1241 cupsCMYKSetCurve(cmyk
, 0, num_xypoints
, xypoints
);
1243 else if ((attr
= cupsFindAttr(ppd
, "cupsCyanGamma", colormodel
, media
,
1244 resolution
, spec
, sizeof(spec
))) != NULL
)
1246 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1247 cupsCMYKSetGamma(cmyk
, 0, gamval
, density
);
1249 else if ((attr
= cupsFindAttr(ppd
, "cupsAllXY", colormodel
, media
,
1250 resolution
, spec
, sizeof(spec
))) != NULL
)
1252 for (num_xypoints
= 0, xyptr
= xypoints
;
1253 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1254 attr
= ppdFindNextAttr(ppd
, "cupsAllXY", spec
))
1255 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1261 cupsCMYKSetCurve(cmyk
, 0, num_xypoints
, xypoints
);
1263 else if ((attr
= cupsFindAttr(ppd
, "cupsAllGamma", colormodel
, media
,
1264 resolution
, spec
, sizeof(spec
))) != NULL
)
1266 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1267 cupsCMYKSetGamma(cmyk
, 0, gamval
, density
);
1271 * Get the optional cupsMagentaXY or cupsMagentaGamma attributes...
1274 if ((attr
= cupsFindAttr(ppd
, "cupsMagentaXY", colormodel
, media
,
1275 resolution
, spec
, sizeof(spec
))) != NULL
)
1277 for (num_xypoints
= 0, xyptr
= xypoints
;
1278 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1279 attr
= ppdFindNextAttr(ppd
, "cupsMagentaXY", spec
))
1280 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1286 switch (num_channels
)
1290 cupsCMYKSetCurve(cmyk
, 1, num_xypoints
, xypoints
);
1294 cupsCMYKSetCurve(cmyk
, 2, num_xypoints
, xypoints
);
1298 else if ((attr
= cupsFindAttr(ppd
, "cupsMagentaGamma", colormodel
, media
,
1299 resolution
, spec
, sizeof(spec
))) != NULL
)
1301 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1302 switch (num_channels
)
1306 cupsCMYKSetGamma(cmyk
, 1, gamval
, density
);
1310 cupsCMYKSetGamma(cmyk
, 2, gamval
, density
);
1314 else if ((attr
= cupsFindAttr(ppd
, "cupsAllXY", colormodel
, media
,
1315 resolution
, spec
, sizeof(spec
))) != NULL
)
1317 for (num_xypoints
= 0, xyptr
= xypoints
;
1318 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1319 attr
= ppdFindNextAttr(ppd
, "cupsAllXY", spec
))
1320 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1326 switch (num_channels
)
1330 cupsCMYKSetCurve(cmyk
, 1, num_xypoints
, xypoints
);
1334 cupsCMYKSetCurve(cmyk
, 2, num_xypoints
, xypoints
);
1338 else if ((attr
= cupsFindAttr(ppd
, "cupsAllGamma", colormodel
, media
,
1339 resolution
, spec
, sizeof(spec
))) != NULL
)
1341 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1342 switch (num_channels
)
1346 cupsCMYKSetGamma(cmyk
, 1, gamval
, density
);
1350 cupsCMYKSetGamma(cmyk
, 2, gamval
, density
);
1356 * Get the optional cupsYellowXY or cupsYellowGamma attributes...
1359 if ((attr
= cupsFindAttr(ppd
, "cupsYellowXY", colormodel
, media
,
1360 resolution
, spec
, sizeof(spec
))) != NULL
)
1362 for (num_xypoints
= 0, xyptr
= xypoints
;
1363 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1364 attr
= ppdFindNextAttr(ppd
, "cupsYellowXY", spec
))
1365 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1371 switch (num_channels
)
1375 cupsCMYKSetCurve(cmyk
, 2, num_xypoints
, xypoints
);
1379 cupsCMYKSetCurve(cmyk
, 4, num_xypoints
, xypoints
);
1383 else if ((attr
= cupsFindAttr(ppd
, "cupsYellowGamma", colormodel
, media
,
1384 resolution
, spec
, sizeof(spec
))) != NULL
)
1386 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1387 switch (num_channels
)
1391 cupsCMYKSetGamma(cmyk
, 2, gamval
, density
);
1395 cupsCMYKSetGamma(cmyk
, 4, gamval
, density
);
1399 else if ((attr
= cupsFindAttr(ppd
, "cupsAllXY", colormodel
, media
,
1400 resolution
, spec
, sizeof(spec
))) != NULL
)
1402 for (num_xypoints
= 0, xyptr
= xypoints
;
1403 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1404 attr
= ppdFindNextAttr(ppd
, "cupsAllXY", spec
))
1405 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1411 switch (num_channels
)
1415 cupsCMYKSetCurve(cmyk
, 2, num_xypoints
, xypoints
);
1419 cupsCMYKSetCurve(cmyk
, 4, num_xypoints
, xypoints
);
1423 else if ((attr
= cupsFindAttr(ppd
, "cupsAllGamma", colormodel
, media
,
1424 resolution
, spec
, sizeof(spec
))) != NULL
)
1426 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1427 switch (num_channels
)
1431 cupsCMYKSetGamma(cmyk
, 2, gamval
, density
);
1435 cupsCMYKSetGamma(cmyk
, 4, gamval
, density
);
1442 * Get the optional cupsLightBlackXY, cupsLightBlackGamma, or
1443 * cupsBlackLtDk attributes...
1446 if (num_channels
== 2 || num_channels
== 7)
1448 if ((attr
= cupsFindAttr(ppd
, "cupsLightBlackXY", colormodel
, media
,
1449 resolution
, spec
, sizeof(spec
))) != NULL
)
1451 for (num_xypoints
= 0, xyptr
= xypoints
;
1452 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1453 attr
= ppdFindNextAttr(ppd
, "cupsLightBlackXY", spec
))
1454 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1460 switch (num_channels
)
1463 cupsCMYKSetCurve(cmyk
, 1, num_xypoints
, xypoints
);
1466 cupsCMYKSetCurve(cmyk
, 6, num_xypoints
, xypoints
);
1470 else if ((attr
= cupsFindAttr(ppd
, "cupsLightBlackGamma", colormodel
,
1471 media
, resolution
, spec
,
1472 sizeof(spec
))) != NULL
)
1474 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1475 switch (num_channels
)
1478 cupsCMYKSetGamma(cmyk
, 1, gamval
, density
);
1481 cupsCMYKSetGamma(cmyk
, 6, gamval
, density
);
1485 else if ((attr
= cupsFindAttr(ppd
, "cupsBlackLtDk", colormodel
, media
,
1486 resolution
, spec
, sizeof(spec
))) != NULL
)
1488 if (sscanf(attr
->value
, "%f%f", &light
, &dark
) == 2)
1489 switch (num_channels
)
1492 cupsCMYKSetLtDk(cmyk
, 0, light
, dark
);
1495 cupsCMYKSetLtDk(cmyk
, 5, light
, dark
);
1499 fprintf(stderr
, "ERROR: Bad cupsBlackLtDk value \"%s\"!\n",
1503 fprintf(stderr
, "WARNING: No light black attribute found for %s!\n",
1507 if (num_channels
>= 6)
1510 * Get the optional cupsLightCyanXY, cupsLightCyanGamma, or
1511 * cupsCyanLtDk attributes...
1514 if ((attr
= cupsFindAttr(ppd
, "cupsLightCyanXY", colormodel
, media
,
1515 resolution
, spec
, sizeof(spec
))) != NULL
)
1517 for (num_xypoints
= 0, xyptr
= xypoints
;
1518 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1519 attr
= ppdFindNextAttr(ppd
, "cupsLightCyanXY", spec
))
1520 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1526 cupsCMYKSetCurve(cmyk
, 1, num_xypoints
, xypoints
);
1528 else if ((attr
= cupsFindAttr(ppd
, "cupsLightCyanGamma", colormodel
,
1529 media
, resolution
, spec
,
1530 sizeof(spec
))) != NULL
)
1532 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1533 cupsCMYKSetGamma(cmyk
, 1, gamval
, density
);
1535 else if ((attr
= cupsFindAttr(ppd
, "cupsCyanLtDk", colormodel
, media
,
1536 resolution
, spec
, sizeof(spec
))) != NULL
)
1538 if (sscanf(attr
->value
, "%f%f", &light
, &dark
) == 2)
1539 cupsCMYKSetLtDk(cmyk
, 0, light
, dark
);
1541 fprintf(stderr
, "ERROR: Bad cupsCyanLtDk value \"%s\"!\n",
1545 fprintf(stderr
, "WARNING: No light cyan attribute found for %s!\n",
1549 * Get the optional cupsLightMagentaXY, cupsLightMagentaGamma, or
1550 * cupsMagentaLtDk attributes...
1553 if ((attr
= cupsFindAttr(ppd
, "cupsLightMagentaXY", colormodel
, media
,
1554 resolution
, spec
, sizeof(spec
))) != NULL
)
1556 for (num_xypoints
= 0, xyptr
= xypoints
;
1557 attr
!= NULL
&& attr
->value
!= NULL
&& num_xypoints
< 100;
1558 attr
= ppdFindNextAttr(ppd
, "cupsLightMagentaXY", spec
))
1559 if (sscanf(attr
->value
, "%f%f", xyptr
, xyptr
+ 1) == 2)
1565 cupsCMYKSetCurve(cmyk
, 3, num_xypoints
, xypoints
);
1567 else if ((attr
= cupsFindAttr(ppd
, "cupsLightMagentaGamma", colormodel
,
1568 media
, resolution
, spec
,
1569 sizeof(spec
))) != NULL
)
1571 if (sscanf(attr
->value
, "%f%f", &gamval
, &density
) == 2)
1572 cupsCMYKSetGamma(cmyk
, 3, gamval
, density
);
1574 else if ((attr
= cupsFindAttr(ppd
, "cupsMagentaLtDk", colormodel
, media
,
1575 resolution
, spec
, sizeof(spec
))) != NULL
)
1577 if (sscanf(attr
->value
, "%f%f", &light
, &dark
) == 2)
1578 cupsCMYKSetLtDk(cmyk
, 2, light
, dark
);
1580 fprintf(stderr
, "ERROR: Bad cupsMagentaLtDk value \"%s\"!\n",
1584 fprintf(stderr
, "WARNING: No light magenta attribute found for %s!\n",
1589 * Return the new profile...
1597 * 'cupsCMYKNew()' - Create a new CMYK color separation.
1600 cups_cmyk_t
* /* O - New CMYK separation or NULL */
1601 cupsCMYKNew(int num_channels
) /* I - Number of color components */
1603 cups_cmyk_t
*cmyk
; /* New color separation */
1604 int i
; /* Looping var */
1608 * Range-check the input...
1611 if (num_channels
< 1)
1615 * Allocate memory for the separation...
1618 if ((cmyk
= calloc(1, sizeof(cups_cmyk_t
))) == NULL
)
1622 * Allocate memory for the LUTs...
1625 cmyk
->num_channels
= num_channels
;
1627 if ((cmyk
->channels
[0] = calloc(num_channels
* 256, sizeof(short))) == NULL
)
1633 for (i
= 1; i
< num_channels
; i
++)
1634 cmyk
->channels
[i
] = cmyk
->channels
[0] + i
* 256;
1637 * Fill in the LUTs with unity transitions...
1640 for (i
= 0; i
< 256; i
++)
1641 cmyk
->black_lut
[i
] = i
;
1643 switch (num_channels
)
1647 for (i
= 0; i
< 256; i
++)
1649 cmyk
->channels
[0][i
] = CUPS_MAX_LUT
* i
/ 255;
1653 for (i
= 0; i
< 256; i
++)
1655 cmyk
->channels
[0][i
] = CUPS_MAX_LUT
* i
/ 255;
1656 cmyk
->channels
[1][i
] = CUPS_MAX_LUT
* i
/ 255;
1657 cmyk
->channels
[2][i
] = CUPS_MAX_LUT
* i
/ 255;
1661 for (i
= 0; i
< 256; i
++)
1663 cmyk
->channels
[0][i
] = CUPS_MAX_LUT
* i
/ 255;
1664 cmyk
->channels
[1][i
] = CUPS_MAX_LUT
* i
/ 255;
1665 cmyk
->channels
[2][i
] = CUPS_MAX_LUT
* i
/ 255;
1666 cmyk
->channels
[3][i
] = CUPS_MAX_LUT
* i
/ 255;
1669 case 6 : /* CcMmYK */
1670 case 7 : /* CcMmYKk */
1671 for (i
= 0; i
< 256; i
++)
1673 cmyk
->channels
[0][i
] = CUPS_MAX_LUT
* i
/ 255;
1674 cmyk
->channels
[2][i
] = CUPS_MAX_LUT
* i
/ 255;
1675 cmyk
->channels
[4][i
] = CUPS_MAX_LUT
* i
/ 255;
1676 cmyk
->channels
[5][i
] = CUPS_MAX_LUT
* i
/ 255;
1682 * Return the separation...
1690 * 'cupsCMYKSetBlack()' - Set the transition range for CMY to black.
1694 cupsCMYKSetBlack(cups_cmyk_t
*cmyk
, /* I - CMYK color separation */
1695 float lower
, /* I - No black ink */
1696 float upper
) /* I - Only black ink */
1698 int i
, /* Looping var */
1699 delta
, /* Difference between lower and upper */
1700 ilower
, /* Lower level from 0 to 255 */
1701 iupper
; /* Upper level from 0 to 255 */
1705 * Range check input...
1708 if (cmyk
== NULL
|| lower
< 0.0 || lower
> 1.0 || upper
< 0.0 || upper
> 1.0 ||
1713 * Convert lower and upper to integers from 0 to 255...
1716 ilower
= (int)(255.0 * lower
+ 0.5);
1717 iupper
= (int)(255.0 * upper
+ 0.5);
1718 delta
= iupper
- ilower
;
1721 * Generate the CMY-only data...
1724 for (i
= 0; i
< ilower
; i
++)
1726 cmyk
->black_lut
[i
] = 0;
1727 cmyk
->color_lut
[i
] = i
;
1731 * Then the transition data...
1734 for (; i
< iupper
; i
++)
1736 cmyk
->black_lut
[i
] = iupper
* (i
- ilower
) / delta
;
1737 cmyk
->color_lut
[i
] = ilower
- ilower
* (i
- ilower
) / delta
;
1741 * Then the K-only data...
1744 for (; i
< 256; i
++)
1746 cmyk
->black_lut
[i
] = i
;
1747 cmyk
->color_lut
[i
] = 0;
1750 fprintf(stderr
, "DEBUG: cupsCMYKSetBlack(cmyk, lower=%.3f, upper=%.3f)\n", lower
, upper
);
1752 for (i
= 0; i
< 256; i
+= 17)
1753 fprintf(stderr
, "DEBUG: %3d = %3dk + %3dc\n", i
,
1754 cmyk
->black_lut
[i
], cmyk
->color_lut
[i
]);
1759 * 'cupsCMYKSetCurve()' - Set a color transform curve using points.
1763 cupsCMYKSetCurve(cups_cmyk_t
*cmyk
, /* I - CMYK color separation */
1764 int channel
, /* I - Color channel */
1766 /* I - Number of X,Y points */
1767 const float *xypoints
) /* I - X,Y points */
1769 int i
; /* Looping var */
1770 int xstart
; /* Start position */
1771 int xend
; /* End position */
1772 int xdelta
; /* Difference in position */
1773 int ystart
; /* Start value */
1774 int yend
; /* End value */
1775 int ydelta
; /* Difference in value */
1779 * Range check input...
1782 if (cmyk
== NULL
|| channel
< 0 || channel
>= cmyk
->num_channels
||
1783 num_xypoints
< 1 || xypoints
== NULL
)
1787 * Initialize the lookup table for the specified channel...
1790 for (xstart
= xend
= 0, ystart
= yend
= 0;
1792 num_xypoints
--, xypoints
+= 2, xstart
= xend
, ystart
= yend
)
1794 xend
= (int)(255.0 * xypoints
[1] + 0.5);
1795 yend
= (int)(CUPS_MAX_LUT
* xypoints
[0] + 0.5);
1796 xdelta
= xend
- xstart
;
1797 ydelta
= yend
- ystart
;
1799 for (i
= xstart
; i
< xend
; i
++)
1800 cmyk
->channels
[channel
][i
] = ystart
+ ydelta
* (i
- xstart
) / xdelta
;
1804 * Initialize any trailing values to the maximum of the last data point...
1807 for (i
= xend
; i
< 256; i
++)
1808 cmyk
->channels
[channel
][i
] = yend
;
1810 fprintf(stderr
, "DEBUG: cupsCMYKSetXY(cmyk, channel=%d, num_xypoints=%d, "
1811 "xypoints=[%.3f %.3f %.3f %.3f ...])\n", channel
,
1812 num_xypoints
, xypoints
[0], xypoints
[1], xypoints
[2], xypoints
[3]);
1814 for (i
= 0; i
< 256; i
+= 17)
1815 fprintf(stderr
, "DEBUG: %3d = %4d\n", i
,
1816 cmyk
->channels
[channel
+ 0][i
]);
1821 * 'cupsCMYKSetGamma()' - Set a color transform curve using gamma and density.
1825 cupsCMYKSetGamma(cups_cmyk_t
*cmyk
, /* I - CMYK color separation */
1826 int channel
, /* I - Ink channel */
1827 float gamval
, /* I - Gamma correction */
1828 float density
) /* I - Maximum density */
1830 int i
; /* Looping var */
1834 * Range check input...
1837 if (cmyk
== NULL
|| channel
< 0 || channel
>= cmyk
->num_channels
||
1838 gamval
<= 0.0 || density
<= 0.0 || density
> 1.0)
1842 * Initialize the lookup table for the specified channel...
1845 for (i
= 0; i
< 256; i
++)
1846 cmyk
->channels
[channel
][i
] = (int)(density
* CUPS_MAX_LUT
*
1847 pow((float)i
/ 255.0, gamval
) + 0.5);
1849 fprintf(stderr
, "DEBUG: cupsCMYKSetGamma(cmyk, channel=%d, gamval=%.3f, "
1850 "density=%.3f)\n", channel
, gamval
, density
);
1852 for (i
= 0; i
< 256; i
+= 17)
1853 fprintf(stderr
, "DEBUG: %3d = %4d\n", i
,
1854 cmyk
->channels
[channel
+ 0][i
]);
1859 * 'cupsCMYKSetInkLimit()' - Set the limit on the amount of ink.
1863 cupsCMYKSetInkLimit(cups_cmyk_t
*cmyk
, /* I - CMYK color separation */
1864 float limit
) /* I - Limit of ink */
1866 if (!cmyk
|| limit
< 0.0)
1869 cmyk
->ink_limit
= limit
* CUPS_MAX_LUT
;
1874 * 'cupsCMYKSetLtDk()' - Set light/dark ink transforms.
1878 cupsCMYKSetLtDk(cups_cmyk_t
*cmyk
, /* I - CMYK color separation */
1879 int channel
, /* I - Dark ink channel (+1 for light) */
1880 float light
, /* I - Light ink only level */
1881 float dark
) /* I - Dark ink only level */
1883 int i
, /* Looping var */
1884 delta
, /* Difference between lower and upper */
1885 ilight
, /* Light level from 0 to 255 */
1886 idark
; /* Dark level from 0 to 255 */
1887 short lut
[256]; /* Original LUT data */
1891 * Range check input...
1894 if (cmyk
== NULL
|| light
< 0.0 || light
> 1.0 || dark
< 0.0 || dark
> 1.0 ||
1895 light
> dark
|| channel
< 0 || channel
> (cmyk
->num_channels
- 2))
1899 * Convert lower and upper to integers from 0 to 255...
1902 ilight
= (int)(255.0 * light
+ 0.5);
1903 idark
= (int)(255.0 * dark
+ 0.5);
1904 delta
= idark
- ilight
;
1907 * Copy the dark ink LUT...
1910 memcpy(lut
, cmyk
->channels
[channel
], sizeof(lut
));
1913 * Generate the light-only data...
1916 for (i
= 0; i
< ilight
; i
++)
1918 cmyk
->channels
[channel
+ 0][i
] = 0;
1919 cmyk
->channels
[channel
+ 1][i
] = CUPS_MAX_LUT
* i
/ ilight
;
1923 * Then the transition data...
1926 for (; i
< idark
; i
++)
1928 cmyk
->channels
[channel
+ 0][i
] = CUPS_MAX_LUT
* idark
* (i
- ilight
) /
1930 cmyk
->channels
[channel
+ 1][i
] = CUPS_MAX_LUT
- CUPS_MAX_LUT
*
1931 (i
- ilight
) / delta
;
1935 * Then the K-only data...
1938 for (; i
< 256; i
++)
1940 cmyk
->channels
[channel
+ 0][i
] = CUPS_MAX_LUT
* i
/ 255;
1941 cmyk
->channels
[channel
+ 1][i
] = 0;
1944 fprintf(stderr
, "DEBUG: cupsCMYKSetLtDk(cmyk, channel=%d, light=%.3f, "
1945 "dark=%.3f)\n", channel
, light
, dark
);
1947 for (i
= 0; i
< 256; i
+= 17)
1948 fprintf(stderr
, "DEBUG: %3d = %4dlt + %4ddk\n", i
,
1949 cmyk
->channels
[channel
+ 0][i
], cmyk
->channels
[channel
+ 1][i
]);