~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/widgets/iccprofiles/cietonguewidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
namespace Digikam
54
54
{
55
55
 
56
 
    /**
57
 
    The following table gives the CIE  color matching functions
58
 
    \f$\bar{x}(\lambda)\f$, \f$\bar{y}(\lambda)\f$, and
59
 
    \f$\bar{z}(\lambda)\f$, for wavelengths \f$\lambda\f$ at 5 nanometer
60
 
    increments from 380 nm through 780 nm. This table is used in conjunction
61
 
    with Planck's law for the energy spectrum of a black body at a given
62
 
    temperature to plot the black body curve on the CIE chart.
 
56
/**
 
57
The following table gives the CIE  color matching functions
 
58
\f$\bar{x}(\lambda)\f$, \f$\bar{y}(\lambda)\f$, and
 
59
\f$\bar{z}(\lambda)\f$, for wavelengths \f$\lambda\f$ at 5 nanometer
 
60
increments from 380 nm through 780 nm. This table is used in conjunction
 
61
with Planck's law for the energy spectrum of a black body at a given
 
62
temperature to plot the black body curve on the CIE chart.
63
63
 
64
 
    The following table gives the spectral chromaticity co-ordinates
65
 
    \f$x(\lambda)\f$ and \f$y(\lambda)\f$ for wavelengths in 5 nanometer
66
 
    increments from 380 nm through 780 nm. These coordinates represent the
67
 
    position in the CIE x-y space of pure spectral colors of the given
68
 
    wavelength, and thus define the outline of the CIE "tongue" diagram.
69
 
    */
70
 
    static const double spectral_chromaticity[81][3] =
71
 
    {
72
 
        { 0.1741, 0.0050 },               // 380 nm
73
 
        { 0.1740, 0.0050 },
74
 
        { 0.1738, 0.0049 },
75
 
        { 0.1736, 0.0049 },
76
 
        { 0.1733, 0.0048 },
77
 
        { 0.1730, 0.0048 },
78
 
        { 0.1726, 0.0048 },
79
 
        { 0.1721, 0.0048 },
80
 
        { 0.1714, 0.0051 },
81
 
        { 0.1703, 0.0058 },
82
 
        { 0.1689, 0.0069 },
83
 
        { 0.1669, 0.0086 },
84
 
        { 0.1644, 0.0109 },
85
 
        { 0.1611, 0.0138 },
86
 
        { 0.1566, 0.0177 },
87
 
        { 0.1510, 0.0227 },
88
 
        { 0.1440, 0.0297 },
89
 
        { 0.1355, 0.0399 },
90
 
        { 0.1241, 0.0578 },
91
 
        { 0.1096, 0.0868 },
92
 
        { 0.0913, 0.1327 },
93
 
        { 0.0687, 0.2007 },
94
 
        { 0.0454, 0.2950 },
95
 
        { 0.0235, 0.4127 },
96
 
        { 0.0082, 0.5384 },
97
 
        { 0.0039, 0.6548 },
98
 
        { 0.0139, 0.7502 },
99
 
        { 0.0389, 0.8120 },
100
 
        { 0.0743, 0.8338 },
101
 
        { 0.1142, 0.8262 },
102
 
        { 0.1547, 0.8059 },
103
 
        { 0.1929, 0.7816 },
104
 
        { 0.2296, 0.7543 },
105
 
        { 0.2658, 0.7243 },
106
 
        { 0.3016, 0.6923 },
107
 
        { 0.3373, 0.6589 },
108
 
        { 0.3731, 0.6245 },
109
 
        { 0.4087, 0.5896 },
110
 
        { 0.4441, 0.5547 },
111
 
        { 0.4788, 0.5202 },
112
 
        { 0.5125, 0.4866 },
113
 
        { 0.5448, 0.4544 },
114
 
        { 0.5752, 0.4242 },
115
 
        { 0.6029, 0.3965 },
116
 
        { 0.6270, 0.3725 },
117
 
        { 0.6482, 0.3514 },
118
 
        { 0.6658, 0.3340 },
119
 
        { 0.6801, 0.3197 },
120
 
        { 0.6915, 0.3083 },
121
 
        { 0.7006, 0.2993 },
122
 
        { 0.7079, 0.2920 },
123
 
        { 0.7140, 0.2859 },
124
 
        { 0.7190, 0.2809 },
125
 
        { 0.7230, 0.2770 },
126
 
        { 0.7260, 0.2740 },
127
 
        { 0.7283, 0.2717 },
128
 
        { 0.7300, 0.2700 },
129
 
        { 0.7311, 0.2689 },
130
 
        { 0.7320, 0.2680 },
131
 
        { 0.7327, 0.2673 },
132
 
        { 0.7334, 0.2666 },
133
 
        { 0.7340, 0.2660 },
134
 
        { 0.7344, 0.2656 },
135
 
        { 0.7346, 0.2654 },
136
 
        { 0.7347, 0.2653 },
137
 
        { 0.7347, 0.2653 },
138
 
        { 0.7347, 0.2653 },
139
 
        { 0.7347, 0.2653 },
140
 
        { 0.7347, 0.2653 },
141
 
        { 0.7347, 0.2653 },
142
 
        { 0.7347, 0.2653 },
143
 
        { 0.7347, 0.2653 },
144
 
        { 0.7347, 0.2653 },
145
 
        { 0.7347, 0.2653 },
146
 
        { 0.7347, 0.2653 },
147
 
        { 0.7347, 0.2653 },
148
 
        { 0.7347, 0.2653 },
149
 
        { 0.7347, 0.2653 },
150
 
        { 0.7347, 0.2653 },
151
 
        { 0.7347, 0.2653 },
152
 
        { 0.7347, 0.2653 }  // 780 nm
153
 
    };
 
64
The following table gives the spectral chromaticity co-ordinates
 
65
\f$x(\lambda)\f$ and \f$y(\lambda)\f$ for wavelengths in 5 nanometer
 
66
increments from 380 nm through 780 nm. These coordinates represent the
 
67
position in the CIE x-y space of pure spectral colors of the given
 
68
wavelength, and thus define the outline of the CIE "tongue" diagram.
 
69
*/
 
70
static const double spectral_chromaticity[81][3] =
 
71
{
 
72
    { 0.1741, 0.0050 },               // 380 nm
 
73
    { 0.1740, 0.0050 },
 
74
    { 0.1738, 0.0049 },
 
75
    { 0.1736, 0.0049 },
 
76
    { 0.1733, 0.0048 },
 
77
    { 0.1730, 0.0048 },
 
78
    { 0.1726, 0.0048 },
 
79
    { 0.1721, 0.0048 },
 
80
    { 0.1714, 0.0051 },
 
81
    { 0.1703, 0.0058 },
 
82
    { 0.1689, 0.0069 },
 
83
    { 0.1669, 0.0086 },
 
84
    { 0.1644, 0.0109 },
 
85
    { 0.1611, 0.0138 },
 
86
    { 0.1566, 0.0177 },
 
87
    { 0.1510, 0.0227 },
 
88
    { 0.1440, 0.0297 },
 
89
    { 0.1355, 0.0399 },
 
90
    { 0.1241, 0.0578 },
 
91
    { 0.1096, 0.0868 },
 
92
    { 0.0913, 0.1327 },
 
93
    { 0.0687, 0.2007 },
 
94
    { 0.0454, 0.2950 },
 
95
    { 0.0235, 0.4127 },
 
96
    { 0.0082, 0.5384 },
 
97
    { 0.0039, 0.6548 },
 
98
    { 0.0139, 0.7502 },
 
99
    { 0.0389, 0.8120 },
 
100
    { 0.0743, 0.8338 },
 
101
    { 0.1142, 0.8262 },
 
102
    { 0.1547, 0.8059 },
 
103
    { 0.1929, 0.7816 },
 
104
    { 0.2296, 0.7543 },
 
105
    { 0.2658, 0.7243 },
 
106
    { 0.3016, 0.6923 },
 
107
    { 0.3373, 0.6589 },
 
108
    { 0.3731, 0.6245 },
 
109
    { 0.4087, 0.5896 },
 
110
    { 0.4441, 0.5547 },
 
111
    { 0.4788, 0.5202 },
 
112
    { 0.5125, 0.4866 },
 
113
    { 0.5448, 0.4544 },
 
114
    { 0.5752, 0.4242 },
 
115
    { 0.6029, 0.3965 },
 
116
    { 0.6270, 0.3725 },
 
117
    { 0.6482, 0.3514 },
 
118
    { 0.6658, 0.3340 },
 
119
    { 0.6801, 0.3197 },
 
120
    { 0.6915, 0.3083 },
 
121
    { 0.7006, 0.2993 },
 
122
    { 0.7079, 0.2920 },
 
123
    { 0.7140, 0.2859 },
 
124
    { 0.7190, 0.2809 },
 
125
    { 0.7230, 0.2770 },
 
126
    { 0.7260, 0.2740 },
 
127
    { 0.7283, 0.2717 },
 
128
    { 0.7300, 0.2700 },
 
129
    { 0.7311, 0.2689 },
 
130
    { 0.7320, 0.2680 },
 
131
    { 0.7327, 0.2673 },
 
132
    { 0.7334, 0.2666 },
 
133
    { 0.7340, 0.2660 },
 
134
    { 0.7344, 0.2656 },
 
135
    { 0.7346, 0.2654 },
 
136
    { 0.7347, 0.2653 },
 
137
    { 0.7347, 0.2653 },
 
138
    { 0.7347, 0.2653 },
 
139
    { 0.7347, 0.2653 },
 
140
    { 0.7347, 0.2653 },
 
141
    { 0.7347, 0.2653 },
 
142
    { 0.7347, 0.2653 },
 
143
    { 0.7347, 0.2653 },
 
144
    { 0.7347, 0.2653 },
 
145
    { 0.7347, 0.2653 },
 
146
    { 0.7347, 0.2653 },
 
147
    { 0.7347, 0.2653 },
 
148
    { 0.7347, 0.2653 },
 
149
    { 0.7347, 0.2653 },
 
150
    { 0.7347, 0.2653 },
 
151
    { 0.7347, 0.2653 },
 
152
    { 0.7347, 0.2653 }  // 780 nm
 
153
};
154
154
 
155
155
class CIETongueWidget::CIETongueWidgetPriv
156
156
{
209
209
};
210
210
 
211
211
CIETongueWidget::CIETongueWidget(int w, int h, QWidget* parent, cmsHPROFILE hMonitor)
212
 
               : QWidget(parent), d(new CIETongueWidgetPriv)
 
212
    : QWidget(parent), d(new CIETongueWidgetPriv)
213
213
{
214
214
    d->progressTimer = new QTimer(this);
215
215
    setMinimumSize(w, h);
384
384
    if (cmsTakeCharTargetData(hProfile, &CharTarget, &CharTargetSize))
385
385
    {
386
386
        LCMSHANDLE hSheet = cmsxIT8LoadFromMem(CharTarget, CharTargetSize);
 
387
 
387
388
        if (hSheet != NULL)
388
389
        {
389
390
            cmsxPCollLoadFromSheet(&(d->Measurement),  hSheet);
441
442
        int ix = (x - 380) / 5;
442
443
 
443
444
        cmsCIExyY p = {spectral_chromaticity[ix][0],
444
 
                       spectral_chromaticity[ix][1], 1};
 
445
                       spectral_chromaticity[ix][1], 1
 
446
                      };
445
447
 
446
448
        int icx, icy;
447
449
        mapPoint(icx, icy, &p);
458
460
 
459
461
        lx = icx;
460
462
        ly = icy;
461
 
     }
 
463
    }
462
464
 
463
465
    biasedLine(lx, ly, fx, fy);
464
466
}
574
576
        int ix = (x - 380) / 5;
575
577
 
576
578
        cmsCIExyY p = {spectral_chromaticity[ix][0],
577
 
                       spectral_chromaticity[ix][1], 1};
 
579
                       spectral_chromaticity[ix][1], 1
 
580
                      };
578
581
 
579
582
        int icx, icy;
580
583
        mapPoint(icx, icy, &p);
620
623
            {
621
624
                if (p->XYZ.Y < 0.03)
622
625
                {
623
 
                   continue;
 
626
                    continue;
624
627
                }
625
628
 
626
629
                if (p->XYZProof.Y < 0.03)
627
630
                {
628
 
                   continue;
 
631
                    continue;
629
632
                }
630
633
 
631
634
                cmsCIExyY Pt;
675
678
    hsRGB = cmsCreate_sRGBProfile();
676
679
 
677
680
    cmsHTRANSFORM xform = cmsCreateTransform(hsRGB, TYPE_RGB_16, hXYZ, TYPE_XYZ_16,
678
 
                                             INTENT_ABSOLUTE_COLORIMETRIC, cmsFLAGS_NOTPRECALC);
 
681
                          INTENT_ABSOLUTE_COLORIMETRIC, cmsFLAGS_NOTPRECALC);
679
682
    WORD RGB[3], XYZ[3];
680
683
    cmsCIEXYZ xyz, MediaWhite;
681
684
    cmsCIExyY xyY, WhitePt;
690
693
        {
691
694
            for (b=0; b < 65536; b += 1024)
692
695
            {
693
 
                RGB[0] = r; RGB[1] = g; RGB[2] = b;
 
696
                RGB[0] = r;
 
697
                RGB[1] = g;
 
698
                RGB[2] = b;
694
699
                cmsDoTransform(xform, RGB, XYZ, 1);
695
700
                cmsXYZEncoded2Float(&xyz, XYZ);
696
701
                cmsXYZ2xyY(&xyY, &xyz);
819
824
 
820
825
        QPixmap anim(d->progressPix.copy(0, d->progressCount*22, 22, 22));
821
826
        d->progressCount++;
 
827
 
822
828
        if (d->progressCount == 8)
823
829
        {
824
830
            d->progressCount = 0;
855
861
        if (d->uncalibratedColor)
856
862
        {
857
863
            p.drawText(0, 0, width(), height(), Qt::AlignCenter,
858
 
                    i18n("Uncalibrated color space"));
 
864
                       i18n("Uncalibrated color space"));
859
865
        }
860
866
        else
861
867
        {
862
868
            p.setPen(Qt::red);
863
869
            p.drawText(0, 0, width(), height(), Qt::AlignCenter,
864
 
                    i18n("No profile available..."));
 
870
                       i18n("No profile available..."));
865
871
        }
866
872
 
867
873
        return;