~noskcaj/ubuntu/trusty/argyll/merge

« back to all changes in this revision

Viewing changes to target/targen.c

  • Committer: Bazaar Package Importer
  • Author(s): Roland Mas
  • Date: 2009-12-10 17:26:04 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091210172604-pfjrmh0cag9hn0x8
Tags: 1.1.0~rc2-1
* New upstream pre-release.
* Updated location of Bazaar branches in control file.
* The Debian-specific branch now feeds from the "midstream" branch
  rather than the "upstream-releases" branch, to ease collaboration with
  other distributions.  This shouldn't make any difference on the
  package contents.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
 */
31
31
 
 
32
/* NOTE:
 
33
 
 
34
        The device model is assumed to not take xpow into account,
 
35
        hence the expected values don't reflect its effect.
 
36
        The general filter is applied prior to the xpow being applied.
 
37
        Many of the test patch types do take it into account
 
38
        when computing the ink limit.
 
39
        The ones that don't are the more complicated full spread patches.
 
40
 
 
41
 */
 
42
 
32
43
/* Description:
33
44
 
34
45
   >> THIS NEEDS REVISION <<
83
94
#undef DEBUG
84
95
 
85
96
#define VRML_DIAG               /* Enable option to dump a VRML of the resulting full spread points */
86
 
#define ADDRECCLIPPOINTS        /* Add ink limited clipping points to regular grid */
 
97
#undef ADDRECCLIPPOINTS /* Add ink limited clipping points to regular grid */
87
98
#define EMPH_NEUTRAL    /* Emphasise neutral axis, like CIE94 does */
88
99
#define NEF 1.0                 /* Amount to emphasis neutral axis, 0 = none, 1 = CIE94 */
89
100
#define DEFANGLE 0.3333 /* For simdlat and simplat */
170
181
 
171
182
 
172
183
/* Absolute XYZ conversion function */
173
 
/* Device values 0.0 - 1.0 are converted into XYZ values */
 
184
/* Internal device values 0.0 - 1.0 are converted into XYZ values */
174
185
/* (Used for downstream checking) */
175
186
static void
176
187
pcpt_to_XYZ(pcpt *s, double *out, double *in) {
200
211
 
201
212
 
202
213
/* Relative Lab conversion function */
203
 
/* Device values 0.0 - 1.0 are converted into Lab values */
 
214
/* Internal device values 0.0 - 1.0 are converted into Lab values */
204
215
/* (Used for VRML visualisation checking) */
205
216
static void
206
217
pcpt_to_rLab(pcpt *s, double *out, double *in) {
229
240
}
230
241
 
231
242
/* Perceptual conversion function */
232
 
/* Device values 0.0 - 1.0 are converted into perceptually uniform 0.0 - 100.0 */
 
243
/* Internal device values 0.0 - 1.0 are converted into perceptually uniform 0.0 - 100.0 */
233
244
static void
234
245
pcpt_to_nLab(pcpt *s, double *out, double *in) {
235
246
        int e;
611
622
        s->xmask = xmask;
612
623
        s->nmask = nmask;
613
624
        s->di = icx_noofinks(nmask);
 
625
 
614
626
        /* See if we have a profile */
615
627
        if (profName != NULL
616
628
         && profName[0] != '\000'
780
792
                        fprintf(stderr,"                 %d: %s\n",i+1,desc);
781
793
                }
782
794
        }
783
 
        fprintf(stderr," -G              Generate good optimzed points rather than Fast\n");
784
 
        fprintf(stderr," -e patches      White test patches (default 4)\n");
785
 
        fprintf(stderr," -s steps        Single channel steps (default grey 50, color 0)\n");
786
 
        fprintf(stderr," -g steps        Grey axis RGB or CMY steps (default 0)\n");
787
 
        fprintf(stderr," -m steps        Multidimensional device space cube steps (default 0)\n");
788
 
        fprintf(stderr," -f patches      Add iterative & adaptive full spread patches to total (default grey 0, color 836)\n");
789
 
        fprintf(stderr,"                 Default is Optimised Farthest Point Sampling (OFPS)\n");
790
 
        fprintf(stderr,"  -t             Use incremental far point for full spread\n");
791
 
        fprintf(stderr,"  -r             Use device space random for full spread\n");
792
 
        fprintf(stderr,"  -R             Use perceptual space random for full spread\n");
793
 
        fprintf(stderr,"  -q             Use device space-filling quasi-random for full spread\n");
794
 
        fprintf(stderr,"  -Q             Use perceptual space-filling quasi-random for full spread\n");
795
 
        fprintf(stderr,"  -i             Use device space body centered cubic grid for full spread\n");
796
 
        fprintf(stderr,"  -I             Use perceptual space body centered cubic grid for full spread\n");
797
 
        fprintf(stderr,"  -a angle       Simplex grid angle 0.0 - 0.5 for B.C.C. grid, default %f\n",DEFANGLE);
798
 
        fprintf(stderr,"  -A adaptation  Degree of adaptation of OFPS 0.0 - 1.0 (default 0.1, 1.0 if -c profile provided)\n");
 
795
        fprintf(stderr," -G               Generate good optimzed points rather than Fast\n");
 
796
        fprintf(stderr," -e patches       White test patches (default 4)\n");
 
797
        fprintf(stderr," -s steps         Single channel steps (default grey 50, color 0)\n");
 
798
        fprintf(stderr," -g steps         Grey axis RGB or CMY steps (default 0)\n");
 
799
        fprintf(stderr," -m steps         Multidimensional device space cube steps (default 0)\n");
 
800
        fprintf(stderr," -f patches       Add iterative & adaptive full spread patches to total (default grey 0, color 836)\n");
 
801
        fprintf(stderr,"                  Default is Optimised Farthest Point Sampling (OFPS)\n");
 
802
        fprintf(stderr,"  -t              Use incremental far point for full spread\n");
 
803
        fprintf(stderr,"  -r              Use device space random for full spread\n");
 
804
        fprintf(stderr,"  -R              Use perceptual space random for full spread\n");
 
805
        fprintf(stderr,"  -q              Use device space-filling quasi-random for full spread\n");
 
806
        fprintf(stderr,"  -Q              Use perceptual space-filling quasi-random for full spread\n");
 
807
        fprintf(stderr,"  -i              Use device space body centered cubic grid for full spread\n");
 
808
        fprintf(stderr,"  -I              Use perceptual space body centered cubic grid for full spread\n");
 
809
        fprintf(stderr,"  -a angle        Simplex grid angle 0.0 - 0.5 for B.C.C. grid, default %f\n",DEFANGLE);
 
810
        fprintf(stderr,"  -A adaptation   Degree of adaptation of OFPS 0.0 - 1.0 (default 0.1, 1.0 if -c profile provided)\n");
799
811
/* Research options: */
800
 
/*      fprintf(stderr,"  -A pPERCWGHT   Device (0.0) ... Perceptual (1.0) weighting\n"); */
801
 
/*      fprintf(stderr,"  -A cCURVEWGHT  Curvature weighting  0.0 = none ... "); */
802
 
        fprintf(stderr," -l ilimit       Total ink limit in %%(default = none) \n");
803
 
        fprintf(stderr," -c profile      Optional device ICC or MPP pre-conditioning profile filename\n");
804
 
        fprintf(stderr,"                 (Use \"none\" to turn off any conditioning)\n");
805
 
        fprintf(stderr," -F L,a,b,rad    Filter out samples outside Lab sphere.\n");
 
812
/*      fprintf(stderr,"  -A pPERCWGHT    Device (0.0) ... Perceptual (1.0) weighting\n"); */
 
813
/*      fprintf(stderr,"  -A cCURVEWGHT   Curvature weighting  0.0 = none ... "); */
 
814
        fprintf(stderr," -l ilimit        Total ink limit in %%(default = none) \n");
 
815
        fprintf(stderr," -p power         Optional power applied to all device values.\n");
 
816
        fprintf(stderr," -c profile       Optional device ICC or MPP pre-conditioning profile filename\n");
 
817
        fprintf(stderr,"                  (Use \"none\" to turn off any conditioning)\n");
 
818
        fprintf(stderr," -F L,a,b,rad     Filter out samples outside Lab sphere.\n");
806
819
#ifdef VRML_DIAG
807
 
        fprintf(stderr," -w              Dump diagnostic outfilel.wrl file (Lab locations)\n");
808
 
        fprintf(stderr," -W              Dump diagnostic outfiled.wrl file (Device locations)\n");
 
820
        fprintf(stderr," -w               Dump diagnostic outfilel.wrl file (Lab locations)\n");
 
821
        fprintf(stderr," -W               Dump diagnostic outfiled.wrl file (Device locations)\n");
809
822
#endif /* VRML_DIAG */
810
 
        fprintf(stderr," outfile         Base name for output(.ti1)\n");
 
823
        fprintf(stderr," outfile          Base name for output(.ti1)\n");
811
824
        exit(1);
812
825
}
813
826
 
839
852
        int dumpvrml = 0;               /* Dump diagnostic .wrl file */
840
853
#endif /* VRML_DIAG */
841
854
        inkmask xmask = 0;              /* External ink mask combination */
842
 
        inkmask nmask = 0;              /* Working ink mask combination */
 
855
        inkmask nmask = 0;              /* Working ink mask combination (ie. CMY for printer external sRGB) */
843
856
        int di = 0;                             /* Output dimensions */
844
857
        char *ident;                    /* Ink combination identifier (includes possible leading 'i') */
845
858
        int good = 0;                   /* 0 - fast, 1 = good */
846
859
        int esteps = 4;                 /* White color patches */
847
860
        int ssteps = -1;                /* Single channel steps */
 
861
        double xpow = 1.0;              /* Power to apply to all device values created */
848
862
        int gsteps = 0;                 /* Composite grey wedge steps */
849
863
        int msteps = 0;                 /* Regular grid multidimensional steps */
850
864
        int fsteps = -1;                /* Fitted Multidimensional patches */
1076
1090
                                if (na == NULL) usage(0,"Expect argument after -e");
1077
1091
                                if ((tt = atof(na)) > 0.0)
1078
1092
                                        uilimit = ilimit = 0.01 * tt;
1079
 
                                }
 
1093
                        }
 
1094
 
 
1095
                        /* Extra device power to use */
 
1096
                        else if (argv[fa][1] == 'p' || argv[fa][1] == 'P') {
 
1097
                                double tt;
 
1098
                                fa = nfa;
 
1099
                                if (na == NULL) usage(0,"Expect argument after -p");
 
1100
                                if ((tt = atof(na)) > 0.0)
 
1101
                                        xpow = tt;
 
1102
                        }
1080
1103
 
1081
1104
                        /* ICC profile for perceptual linearisation */
1082
1105
                        else if (argv[fa][1] == 'c' || argv[fa][1] == 'C') {
1083
1106
                                fa = nfa;
1084
1107
                                if (na == NULL) usage(0,"Expect argument after -e");
1085
1108
                                strncpy(pname,na,MAXNAMEL-1); pname[MAXNAMEL-1] = '\000';
1086
 
                                }
 
1109
                        }
1087
1110
 
1088
1111
                        /* Filter out samples outside given sphere */
1089
1112
                        else if (argv[fa][1] == 'F') {
1282
1305
        if (pdata->is_specific(pdata))
1283
1306
                pp->add_kword(pp, 0, "ACCURATE_EXPECTED_VALUES", "true", NULL);
1284
1307
 
 
1308
        if (xpow != 1.0) {
 
1309
                sprintf(buf,"%f",xpow);
 
1310
                pp->add_kword(pp, 0, "EXTRA_DEV_POW",buf, NULL);
 
1311
        }
 
1312
 
1285
1313
        /* Only use optimsed full spread if <= 4 dimensions, else use ifarp */
1286
1314
        if (di > 4 
1287
1315
         && userand == 0                /* Not other high D useful method */
1324
1352
 
1325
1353
                        sprintf(buf,"%d",id++);
1326
1354
                        ary[0].c = buf;
 
1355
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1327
1356
                        if (xmask == nmask) {
1328
1357
                                for (e = 0; e < di; e++)
1329
1358
                                        ary[1 + e].d = 100.0 * val[e];
1331
1360
                                for (e = 0; e < di; e++)
1332
1361
                                        ary[1 + e].d = 100.0 * (1.0 - val[e]);
1333
1362
                        }
1334
 
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1335
1363
                        ary[1 + di + 0].d = 100.0 * XYZ[0];
1336
1364
                        ary[1 + di + 1].d = 100.0 * XYZ[1];
1337
1365
                        ary[1 + di + 2].d = 100.0 * XYZ[2];
1358
1386
                for (j = 0; j < di; j++) {
1359
1387
                        for (i = 0; i < ssteps; i++) {
1360
1388
                                int addp, e;
1361
 
                                double val[MXTD];
 
1389
                                double val[MXTD], XYZ[3];
1362
1390
                                cgats_set_elem ary[1 + MXTD + 3];
1363
1391
 
1364
1392
                                addp = 1;                       /* Default add the point */
1365
1393
 
1366
1394
                                for (e = 0; e < di; e++) {
1367
1395
                                        if (e == j)
1368
 
                                                val[e] = (double)i/(ssteps-1);
 
1396
                                                val[e] = pow((double)i/(ssteps-1), xpow);
1369
1397
                                        else
1370
1398
                                                val[e] = 0.0;
1371
1399
                                }
1372
1400
 
 
1401
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
1402
 
 
1403
                                for (e = 0; e < di; e++)
 
1404
                                        val[e] = pow(val[e], xpow);
 
1405
 
1373
1406
                                /* See if it is already in the fixed list */
1374
1407
                                if (fxlist != NULL) {
1375
1408
                                        int k;
1392
1425
                                        addp = 0;
1393
1426
 
1394
1427
                                if (addp) {
1395
 
                                        double XYZ[3];
1396
1428
                
1397
1429
                                        sprintf(buf,"%d",id++);
1398
1430
                                        ary[0].c = buf;
1403
1435
                                                for (e = 0; e < di; e++)
1404
1436
                                                        ary[1 + e].d = 100.0 * (1.0 - val[e]);
1405
1437
                                        }
1406
 
                                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1407
1438
                                        ary[1 + di + 0].d = 100.0 * XYZ[0];
1408
1439
                                        ary[1 + di + 1].d = 100.0 * XYZ[1];
1409
1440
                                        ary[1 + di + 2].d = 100.0 * XYZ[2];
1428
1459
        /* Composite gray wedge steps */
1429
1460
        if (gsteps > 0) {
1430
1461
                int cix[3];             /* Composite indexes */ 
 
1462
 
1431
1463
                sprintf(buf,"%d",gsteps);
1432
1464
                pp->add_kword(pp, 0, "COMP_GREY_STEPS",buf, NULL);
1433
1465
 
1434
 
 
1435
1466
                if (nmask & ICX_ADDITIVE) {     /* Look for the RGB */
1436
1467
                        cix[0] = icx_ink2index(nmask, ICX_RED);
1437
1468
                        cix[1] = icx_ink2index(nmask, ICX_GREEN);
1447
1478
 
1448
1479
                for (i = 0; i < gsteps; i++) {
1449
1480
                        int addp, e;
1450
 
                        double sum, val[MXTD];
 
1481
                        double sum, val[MXTD], XYZ[3];
1451
1482
                        cgats_set_elem ary[1 + MXTD + 3];
1452
1483
 
1453
1484
                        addp = 1;                       /* Default add the point */
1454
 
                        sum = 0.0;
1455
1485
 
1456
1486
                        for (e = 0; e < di; e++) {
1457
1487
                                if (e == cix[0] || e == cix[1] || e == cix[2])
1458
 
                                        sum += val[e] = (double)i/(gsteps-1);
 
1488
                                        val[e] = (double)i/(gsteps-1);
1459
1489
                                else
1460
1490
                                        val[e] = 0.0;
1461
1491
                        }
1462
1492
 
 
1493
                        /* Apply general filter */
 
1494
                        if (filter && dofilt(pdata, filt, val))
 
1495
                                addp = 0;
 
1496
 
 
1497
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
1498
 
 
1499
                        /* Apply xpow and compute sum */
 
1500
                        for (sum = 0.0, e = 0; e < di; e++)
 
1501
                                sum += val[e] = pow(val[e], xpow);
 
1502
 
 
1503
                        if (sum > uilimit)
 
1504
                                addp = 0;
 
1505
 
1463
1506
                        /* See if it is already in the fixed list */
1464
1507
                        if (fxlist != NULL) {
1465
1508
                                int k;
1477
1520
                                        addp = 0;                               /* Don't add the point */
1478
1521
                        }
1479
1522
 
1480
 
                        if (sum > uilimit)
1481
 
                                addp = 0;
1482
 
 
1483
 
                        /* Apply general filter */
1484
 
                        if (filter && dofilt(pdata, filt, val))
1485
 
                                addp = 0;
1486
 
 
1487
1523
                        if (addp) {
1488
 
                                double XYZ[3];
1489
1524
        
1490
1525
                                sprintf(buf,"%d",id++);
1491
1526
                                ary[0].c = buf;
1496
1531
                                        for (e = 0; e < di; e++)
1497
1532
                                                ary[1 + e].d = 100.0 * (1.0 - val[e]);
1498
1533
                                }
1499
 
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1500
1534
                                ary[1 + di + 0].d = 100.0 * XYZ[0];
1501
1535
                                ary[1 + di + 1].d = 100.0 * XYZ[1];
1502
1536
                                ary[1 + di + 2].d = 100.0 * XYZ[2];
1528
1562
                        gc[j] = 0;                      /* init coords */
1529
1563
                        
1530
1564
                for (;;) {      /* For all grid points */
1531
 
                        double val[MXTD];
1532
 
                        double sum;
 
1565
                        double sum, val[MXTD], XYZ[3];
1533
1566
                        int addp, e;
1534
1567
 
1535
1568
                        addp = 1;                       /* Default add the point */
1536
1569
 
1537
 
                        for (sum = 0.0, e = 0; e < di; e++) {
1538
 
                                sum += val[e] = (double)gc[e]/(msteps-1);
1539
 
                        }
 
1570
                        for (e = 0; e < di; e++)
 
1571
                                val[e] = (double)gc[e]/(msteps-1);
 
1572
 
 
1573
                        /* Apply general filter */
 
1574
                        if (filter && dofilt(pdata, filt, val))
 
1575
                                addp = 0;
 
1576
 
 
1577
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
1578
 
 
1579
                        for (sum = 0.0, e = 0; e < di; e++)
 
1580
                                sum += val[e] = pow(val[e], xpow);
 
1581
 
1540
1582
                        if (sum > uilimit)
1541
1583
                                addp = 0;               /* Don't add patches over ink limit */
1542
1584
 
1557
1599
                                        addp = 0;                               /* Don't add the point */
1558
1600
                        }
1559
1601
 
1560
 
                        /* Apply general filter */
1561
 
                        if (filter && dofilt(pdata, filt, val))
1562
 
                                addp = 0;
1563
 
 
1564
1602
                        /* Add patch to list if OK */
1565
1603
                        if (addp) {
1566
 
                                double XYZ[3];
1567
1604
                                cgats_set_elem ary[1 + MXTD + 3];
1568
1605
 
1569
1606
                                sprintf(buf,"%d",id++);
1570
1607
                                ary[0].c = buf;
1571
 
 
1572
1608
                                if (xmask == nmask) {
1573
1609
                                        for (e = 0; e < di; e++)
1574
1610
                                                ary[1 + e].d = 100.0 * val[e];
1576
1612
                                        for (e = 0; e < di; e++)
1577
1613
                                                ary[1 + e].d = 100.0 * (1.0 - val[e]);
1578
1614
                                }
1579
 
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1580
1615
                                ary[1 + di + 0].d = 100.0 * XYZ[0];
1581
1616
                                ary[1 + di + 1].d = 100.0 * XYZ[1];
1582
1617
                                ary[1 + di + 2].d = 100.0 * XYZ[2];
1610
1645
#ifdef ADDRECCLIPPOINTS
1611
1646
                /* Add extra points that intersect */
1612
1647
                /* grid, and lie on ink limit plane */
 
1648
                /* !!!!!!!!!! this doesn't cope with xpow !!!!!!!!!!! */
1613
1649
                if (uilimit < (di * 100.0)) {
1614
1650
                        double val[MXTD], tv;
 
1651
                        double XYZ[3];
1615
1652
                        for (k = 0; k < di; k++) {      /* dimension not on grid */
1616
1653
                                for (j = 0; j < di; j++)
1617
1654
                                        gc[j] = 0;                      /* init coords */
1655
1692
                                                        }
1656
1693
 
1657
1694
                                                        if (addp) {
1658
 
                                                                double XYZ[3];
1659
1695
                                                                sprintf(buf,"%d",id++);
1660
1696
                                                                ary[0].c = buf;
1661
 
                                
 
1697
                                                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1662
1698
                                                                if (xmask == nmask) {
1663
1699
                                                                        for (e = 0; e < di; e++)
1664
1700
                                                                                ary[1 + e].d = 100.0 * val[e];
1666
1702
                                                                        for (e = 0; e < di; e++)
1667
1703
                                                                                ary[1 + e].d = 100.0 * (1.0 - val[e]);
1668
1704
                                                                }
1669
 
                                                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1670
1705
                                                                ary[1 + di + 0].d = 100.0 * XYZ[0];
1671
1706
                                                                ary[1 + di + 1].d = 100.0 * XYZ[1];
1672
1707
                                                                ary[1 + di + 2].d = 100.0 * XYZ[2];
1726
1761
                                if (sl != NULL) {
1727
1762
                                        if (sl->next(sl, val))
1728
1763
                                                error("Run out of sobol random numbers!");
1729
 
 
1730
 
                                        for (sum = 0.0, e = 0; e < di; e++)
1731
 
                                                sum += val[e];
1732
1764
                                } else {        /* else uniform random distribution */
1733
 
                                        for (sum = 0.0, e = 0; e < di; e++)
1734
 
                                                sum += val[e] = d_rand(0.0, 1.0);
 
1765
                                        for (e = 0; e < di; e++)
 
1766
                                                val[e] = d_rand(0.0, 1.0);
1735
1767
                                }
1736
1768
 
 
1769
                                /* Apply general filter */
 
1770
                                if (filter && dofilt(pdata, filt, val))
 
1771
                                        continue;
 
1772
 
 
1773
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
1774
 
 
1775
                                for (sum = 0.0, e = 0; e < di; e++)
 
1776
                                        sum += val[e] = pow(val[e], xpow);
 
1777
 
1737
1778
                                if (sum > uilimit)
1738
1779
                                        continue;
1739
1780
 
1740
 
                                /* Apply general filter */
1741
 
                                if (filter && dofilt(pdata, filt, val))
1742
 
                                        continue;
1743
 
 
1744
1781
                                sprintf(buf,"%d",id++);
1745
1782
                                ary[0].c = buf;
1746
1783
                                if (xmask == nmask) {
1750
1787
                                        for (e = 0; e < di; e++)
1751
1788
                                                ary[1 + e].d = 100.0 * (1.0 - val[e]);
1752
1789
                                }
1753
 
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1754
1790
                                ary[1 + di + 0].d = 100.0 * XYZ[0];
1755
1791
                                ary[1 + di + 1].d = 100.0 * XYZ[1];
1756
1792
                                ary[1 + di + 2].d = 100.0 * XYZ[2];
1793
1829
                        simplat *px = NULL;
1794
1830
                        prand *rx = NULL;
1795
1831
 
 
1832
                        /* (Note that the ink limit won't take into account the xpow) */
1796
1833
                        if (uselat)      {
1797
1834
                                t = new_ifarp(di, uilimit, fsteps, fxlist, fxno,
1798
1835
                                                (void(*)(void *, double *, double *))pdata->dev_to_perc, (void *)pdata);
1847
1884
                                if (filter && dofilt(pdata, filt, val))
1848
1885
                                        continue;
1849
1886
 
 
1887
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
1888
 
 
1889
                                /* Apply any device power */
 
1890
                                for (e = 0; e < di; e++)
 
1891
                                        val[e] = pow(val[e], xpow);
 
1892
 
 
1893
                                /* Do a simple ink limit */
 
1894
                                if (uilimit < (double)di) {
 
1895
                                        double tot = 0.0;
 
1896
                                        for (e = 0; e < di; e++)
 
1897
                                                tot += val[e];
 
1898
                                        if (tot > uilimit) {
 
1899
                                                for (e = 0; e < di; e++)
 
1900
                                                        val[e] *= uilimit/tot;
 
1901
                                        }
 
1902
                                }
 
1903
 
1850
1904
                                sprintf(buf,"%d",id++);
1851
1905
                                ary[0].c = buf;
1852
 
                                
1853
1906
                                if (xmask == nmask) {
1854
1907
                                        for (e = 0; e < di; e++)
1855
1908
                                                ary[1 + e].d = 100.0 * val[e];
1857
1910
                                        for (e = 0; e < di; e++)
1858
1911
                                                ary[1 + e].d = 100.0 * (1.0 - val[e]);
1859
1912
                                }
1860
 
                                pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1861
1913
                                ary[1 + di + 0].d = 100.0 * XYZ[0];
1862
1914
                                ary[1 + di + 1].d = 100.0 * XYZ[1];
1863
1915
                                ary[1 + di + 2].d = 100.0 * XYZ[2];
1919
1971
                        pdata->den_to_dev(pdata, val, den);     
1920
1972
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
1921
1973
 
 
1974
                        /* Apply extra power */
 
1975
                        for (e = 0; e < di; e++)
 
1976
                                val[e] = pow(val[e], xpow);
 
1977
 
 
1978
                        /* Do a simple ink limit */
 
1979
                        if (uilimit < (double)di) {
 
1980
                                double tot = 0.0;
 
1981
                                for (e = 0; e < di; e++)
 
1982
                                        tot += val[e];
 
1983
                                if (tot > uilimit) {
 
1984
                                        for (e = 0; e < di; e++)
 
1985
                                                val[e] *= uilimit/tot;
 
1986
                                }
 
1987
                        }
 
1988
 
1922
1989
                        ary[0].i = i;
 
1990
 
1923
1991
                        if (xmask == nmask) {
1924
1992
                                for (e = 0; e < di; e++)
1925
1993
                                        ary[1 + e].d = 100.0 * val[e];
1994
2062
                        if (ftarg != NULL) {
1995
2063
                                ftarg->dev_to_rLab(ftarg, lab, val);
1996
2064
                                pdata->rLab_to_dev(pdata, val, lab);    
1997
 
 
1998
 
                        } else if (uilimit < (double)di) {      /* Do a simple ink limit */
 
2065
                        }
 
2066
 
 
2067
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
 
2068
 
 
2069
                        /* Apply extra power */
 
2070
                        for (e = 0; e < di; e++)
 
2071
                                val[e] = pow(val[e], xpow);
 
2072
 
 
2073
                        /* Do a simple ink limit */
 
2074
                        if (uilimit < (double)di) {
1999
2075
                                double tot = 0.0;
2000
2076
                                for (e = 0; e < di; e++)
2001
2077
                                        tot += val[e];
2004
2080
                                                val[e] *= uilimit/tot;
2005
2081
                                }
2006
2082
                        }
2007
 
                        pdata->dev_to_XYZ(pdata, XYZ, val);             /* Add expected XYZ */
2008
2083
 
2009
2084
                        ary[0].i = i;
2010
2085
                        if (xmask == nmask) {