summaryrefslogtreecommitdiffstats
path: root/debian/lcms/lcms-1.19.dfsg2/Delphi/Samples/testwp.pas
blob: 3804033ec7b5c0adc1d745eae63c07972b5cca9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
program TestWhitePoint;
uses lcmsdll;

type
     RGB8 = Packed record
                r, g, b : Byte
     END;

     CMYK8 = Packed record
                c, m, y, k: Byte
             end;
var
     WhitePoint: cmsCIExyY;
     Primaries: cmsCIExyYTRIPLE;
     Gamma: Array [1..3] OF LPGAMMATABLE;
     InputProfile, OutputProfile : cmsHPROFILE;
     Transform: cmsHTRANSFORM;
     InRGB8: RGB8;
     OutCMYK8: CMYK8;


begin

       cmsWhitePointFromTemp(9300, @WhitePoint);

       Primaries.Red.x := 0.67;
       Primaries.Red.y := 0.33;
       Primaries.Red.YY := 1.0;
       Primaries.Green.x := 0.21;
       Primaries.Green.y := 0.71;
       Primaries.Green.YY := 1.0;
       Primaries.Blue.x := 0.14;
       Primaries.Blue.y := 0.08;
       Primaries.Blue.YY := 1.0;



       Gamma[1] := cmsBuildGamma(256, 2.0);
       Gamma[2] := cmsBuildGamma(256, 2.0);
       Gamma[3] := cmsBuildGamma(256, 2.0);

       InputProfile  := cmsCreateRGBProfile(@WhitePoint, @Primaries, Gamma);
       OutputProfile := cmsOpenProfileFromFile('CMYK.icm', 'r');


       WriteLn('Input profile : ',  cmsTakeProductName(InputProfile));
       WriteLn('Output profile : ', cmsTakeProductName(OutputProfile));

       Transform := cmsCreateTransform(InputProfile,
                                           TYPE_RGB_8,
                                           OutputProfile,
                                           TYPE_CMYK_8,
                                           INTENT_PERCEPTUAL, 0);

      REPEAT

        Write('R?'); ReadLn(InRGB8.r);
        Write('G?'); ReadLn(InRGB8.g);
        Write('B?'); ReadLn(InRGB8.b);

        cmsDoTransform(Transform,
                        @InRGB8,
                        @OutCMYK8,
                        1);

        Write('C='); WriteLn(OutCMYK8.c);
        Write('M='); WriteLn(OutCMYK8.m);
        Write('Y='); WriteLn(OutCMYK8.y);
        Write('K='); WriteLn(OutCMYK8.k);

     UNTIL ((InRGB8.r = 0) and (InRGB8.g = 0) and (InRGB8.b = 0));


     cmsDeleteTransform(Transform);
     cmsCloseProfile(InputProfile);
     cmsCloseProfile(OutputProfile)
END.