Subversion Repositories Scribus

Rev

Rev 3108 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
3107 subik 7
#ifndef COLORBLIND_H
8
#define COLORBLIND_H
9
 
10
#include <qvariant.h>
11
#include <qcolor.h>
12
#include <qobject.h>
13
 
3108 subik 14
/* $Id: colorblind.h 4430 2006-01-22 22:42:17Z cbradney $ */
15
 
16
/*! \brief This code is an implementation of an algorithm described by Hans Brettel,
3107 subik 17
Francoise Vienot and John Mollon in the Journal of the Optical Society of
3108 subik 18
America V14(10), pg 2647. (See http://vischeck.com/ for more info.).
3107 subik 19
 
20
Based on the GIMP's cdisplay_colorblind.c
21
by Michael Natterer <mitch@gimp.org>, Sven Neumann <sven@gimp.org>,
22
Robert Dougherty <bob@vischeck.com> and Alex Wade <alex@vischeck.com>.
23
 
24
This code is written using "Scribus coding standard" as a part of the
25
Scribus project (www.scribus.net).
26
 
27
\author Petr Vanek <petr@yarpen.cz>
28
 
29
This program is free software; you can redistribute it and/or modify
30
it under the terms of the GNU General Public License as published by
31
the Free Software Foundation; either version 2 of the License, or
32
(at your option) any later version.
33
 
34
This program is distributed in the hope that it will be useful,
35
but WITHOUT ANY WARRANTY; without even the implied warranty of
36
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
GNU General Public License for more details.
38
 
39
You should have received a copy of the GNU General Public License
40
along with this program; if not, write to the Free Software
41
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42
*/
43
 
44
class VisionDefectColor : public QObject, public QColor
45
{
46
        Q_OBJECT
47
public:
48
        /*! Enumerate Vision Defects for readable ComboBox access */
49
        enum defectMode {
50
                normalVision = 0,
51
                protanopeVision = 1,
52
                deuteranopeVision = 2,
53
                tritanopeVision = 3,
54
                colorBlindnessVision = 4
55
        };
56
 
57
        /*! QColor like constructors. Setup the RGB parts, then init().
58
        \param r red part of the color
59
        \param g green part of the color
60
        \param b blue part of the color
61
        */
62
        VisionDefectColor(int r, int g, int b);
63
        /*! QColor like constructors. Setup the RGB parts, then init().
64
        \param c QColor object
65
         */
66
        VisionDefectColor(QColor c);
67
 
68
        /*! Actual defect type. One of the 'defectMode' */
69
        int deficiency;
70
 
71
        /*! Perform conversion itself.
72
        Gama removing, RGB2LSM, matrix operation for selected deficiency,
73
        LSM2RGB, gama applying. */
74
        void convertDefect();
75
 
76
        /*! Return the color parts
77
        \retval uint red part
78
        */
79
        uint getRed();
80
        /*! Return the color parts
81
        \retval uint green part
82
        */
83
        uint getGreen();
84
        /*! Return the color parts
85
        \retval uint blue part
86
        */
87
        uint getBlue();
88
        /*! Return QColor
89
        \retval QColor new QColor
90
        */
91
        QColor getColor();
92
 
93
private:
94
        /*! Convert matrix */
95
        double rgb2lms[9];
96
        /*! Convert matrix */
97
        double lms2rgb[9];
98
        /*! Gamma matrix */
99
        double gammaRGB[3];
100
 
101
        /*! cross products with transform matrixes for actual defect */
102
        double a1, b1, c1;
103
        /*! cross products with transform matrixes for actual defect */
104
        double a2, b2, c2;
105
        /*! Inflection border line */
106
        double inflection;
107
 
108
        /*! Internal RGB color parts */
109
        double red, green, blue;
110
 
111
        /*! original color */
112
        QColor originalColor;
113
 
114
        /*! Initialization of the internal values. rgb2lms, lms2rgb etc.
115
        For most modern Cathode-Ray Tube monitors (CRTs), the following
116
        are good estimates of the RGB->LMS and LMS->RGB transform
117
        matrices.  They are based on spectra measured on a typical CRT
118
        with a PhotoResearch PR650 spectral photometer and the Stockman
119
        human cone fundamentals. NOTE: these estimates will NOT work well
120
        for LCDs!
121
        The RGB<->LMS transforms are computed from the human cone
122
        photo-pigment absorption spectra and the monitor phosphor
123
        emission spectra. These parameters are fairly constant for most
124
        humans and most montiors (at least for modern CRTs). However,
125
        gamma will vary quite a bit, as it is a property of the monitor
126
        (eg. amplifier gain), the video card, and even the
127
        software. Further, users can adjust their gammas (either via
128
        adjusting the monitor amp gains or in software). That said, the
129
        following are the gamma estimates that we have used in the
130
        Vischeck code. Many colorblind users have viewed our simulations
131
        and told us that they "work" (simulated and original images are
132
        indistinguishabled).
133
        */
134
        void init();
135
 
136
        /*! This function performs initialisations that are dependant
137
        on the type of color deficiency (see defectMode). */
138
        void setupDefect();
139
 
140
        /*! Ensures that x is between the limits set by low and high.
141
        Glib CLAMP() macro replacement for C++ speedup optimalization.
142
        \param x value itself
143
        \param low low border
144
        \param high high border
145
        \retval double value from interval
146
        */
147
        double clamp(double x, double low, double high);
148
 
149
};
150
 
151
#endif