~ubuntu-branches/ubuntu/feisty/photoprint/feisty

« back to all changes in this revision

Viewing changes to profilemanager/lcmswrapper.h

  • Committer: Bazaar Package Importer
  • Author(s): Milan Zamazal
  • Date: 2006-09-29 12:18:16 UTC
  • Revision ID: james.westby@ubuntu.com-20060929121816-6t2iz9zaymixd3om
Tags: upstream-0.3.3
ImportĀ upstreamĀ versionĀ 0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * lcmswrapper.cpp - encapsulates typical "user" functions of LittleCMS,
 
3
 * providing a Profile and Transform class
 
4
 *
 
5
 * Copyright (c) 2004 by Alastair M. Robinson
 
6
 * Distributed under the terms of the GNU General Public License -
 
7
 * see the file named "COPYING" for more details.
 
8
 *
 
9
 * TODO: Report pixel type, support Lab, XYZ, etc.
 
10
 *
 
11
 */
 
12
 
 
13
#ifndef LCMSWRAPPER_H
 
14
#define LCMSWRAPPER_H
 
15
 
 
16
#ifdef HAVE_CONFIG_H
 
17
#include "config.h"
 
18
#endif
 
19
 
 
20
#include <lcms.h>
 
21
#include "md5.h"
 
22
#include "../imagesource/imagesource_types.h"
 
23
 
 
24
class CMSWhitePoint;
 
25
class CMSRGBPrimaries;
 
26
class CMSRGBGamma;
 
27
class CMSGamma;
 
28
 
 
29
class CMSProfile
 
30
{
 
31
        public:
 
32
        CMSProfile(const char *filename);
 
33
        CMSProfile(char *buffer,int length);
 
34
        CMSProfile(CMSRGBPrimaries &primaries,CMSRGBGamma &gamma,CMSWhitePoint &whitepoint);
 
35
        ~CMSProfile();
 
36
        enum IS_TYPE GetColourSpace();
 
37
        enum IS_TYPE GetDeviceLinkOutputSpace();
 
38
        bool IsDeviceLink();
 
39
        const char *GetName();
 
40
        const char *GetManufacturer();
 
41
        const char *GetModel();
 
42
        const char *GetDescription();
 
43
        const char *GetInfo();
 
44
        const char *GetCopyright();
 
45
        const char *GetFilename();
 
46
        MD5Digest *GetMD5();
 
47
        bool operator==(const CMSProfile &other);
 
48
        protected:
 
49
        MD5Digest *md5;
 
50
        cmsHPROFILE prof;
 
51
        char *filename;
 
52
        friend class CMSTransform;
 
53
};
 
54
 
 
55
 
 
56
class CMSTransform
 
57
{
 
58
        public:
 
59
        CMSTransform(CMSProfile *in,CMSProfile *out,int intent=INTENT_PERCEPTUAL);
 
60
        CMSTransform(CMSProfile *devicelink,int intent=INTENT_PERCEPTUAL);
 
61
        CMSTransform(CMSProfile *profiles[],int profilecount,int intent=INTENT_PERCEPTUAL);
 
62
        ~CMSTransform();
 
63
        void Transform(unsigned short *src,unsigned short *dst,int pixels);
 
64
        enum IS_TYPE GetInputColourSpace();
 
65
        enum IS_TYPE GetOutputColourSpace();
 
66
        private:
 
67
        void MakeTransform(CMSProfile *in,CMSProfile *out,int intent);
 
68
        enum IS_TYPE inputtype;
 
69
        enum IS_TYPE outputtype;
 
70
        cmsHTRANSFORM transform;
 
71
};
 
72
 
 
73
 
 
74
class CMSWhitePoint
 
75
{
 
76
        public:
 
77
        CMSWhitePoint(int degk)
 
78
        {
 
79
                cmsWhitePointFromTemp(degk,&whitepoint);
 
80
        }
 
81
        protected:
 
82
        cmsCIExyY whitepoint;
 
83
        friend class CMSProfile;
 
84
};
 
85
 
 
86
 
 
87
class CMSRGBPrimaries
 
88
{
 
89
        CMSRGBPrimaries(float rx,float ry,float gx,float gy,float bx,float by)
 
90
        {
 
91
                primaries.Red.x=rx;
 
92
                primaries.Red.y=ry;
 
93
                primaries.Red.Y=1.0;
 
94
                primaries.Green.x=gx;
 
95
                primaries.Green.y=gy;
 
96
                primaries.Green.Y=1.0;
 
97
                primaries.Blue.x=bx;
 
98
                primaries.Blue.y=by;
 
99
                primaries.Blue.Y=1.0;   
 
100
        }
 
101
        protected:
 
102
        cmsCIExyYTRIPLE primaries;
 
103
        friend class CMSProfile;
 
104
};
 
105
 
 
106
 
 
107
class CMSGamma
 
108
{
 
109
        public:
 
110
        CMSGamma(float gamma)
 
111
        {
 
112
                gammatable=cmsBuildGamma(256,gamma);
 
113
        }
 
114
        ~CMSGamma()
 
115
        {
 
116
                cmsFreeGamma(gammatable);
 
117
        }
 
118
        protected:
 
119
        LPGAMMATABLE gammatable;
 
120
        friend class CMSProfile;
 
121
        friend class CMSRGBGamma;
 
122
};
 
123
 
 
124
class CMSRGBGamma
 
125
{
 
126
        public:
 
127
        CMSRGBGamma(float rgamma,float ggamma,float bgamma)
 
128
                : redgamma(rgamma),greengamma(ggamma),bluegamma(bgamma)
 
129
        {
 
130
                gammatables[0]=redgamma.gammatable;
 
131
                gammatables[1]=greengamma.gammatable;
 
132
                gammatables[2]=bluegamma.gammatable;
 
133
        }
 
134
        protected:
 
135
        CMSGamma redgamma,greengamma,bluegamma;
 
136
        LPGAMMATABLE gammatables[3];
 
137
        friend class CMSProfile;
 
138
};
 
139
 
 
140
int CMS_GetIntentCount();
 
141
const char *CMS_GetIntentName(int intent);
 
142
const char *CMS_GetIntentDescription(int intent);
 
143
 
 
144
#endif