Rev 15135 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
15127 | jghali | 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 | */ |
||
7 | |||
8 | #include "sclcms2colorprofileimpl.h" |
||
9 | #include "sclcms2colormgmtengineimpl.h" |
||
10 | |||
11 | ScLcms2ColorProfileImpl::ScLcms2ColorProfileImpl(ScColorMgmtEngine& engine, cmsHPROFILE lcmsProfile) |
||
12 | : ScColorProfileImplBase(engine), m_profileHandle(lcmsProfile) |
||
13 | { |
||
14 | |||
15 | } |
||
16 | |||
17 | ScLcms2ColorProfileImpl::~ScLcms2ColorProfileImpl() |
||
18 | { |
||
19 | closeProfile(); |
||
20 | } |
||
21 | |||
22 | bool ScLcms2ColorProfileImpl::isNull() const |
||
23 | { |
||
24 | return (m_profileHandle == NULL); |
||
25 | } |
||
26 | |||
27 | eColorSpaceType ScLcms2ColorProfileImpl::colorSpace() const |
||
28 | { |
||
29 | if (m_profileHandle) |
||
30 | return ScLcms2ColorMgmtEngineImpl::translateLcmsColorSpaceType( cmsGetColorSpace(m_profileHandle) ); |
||
31 | return ColorSpace_Unknown; |
||
32 | } |
||
33 | |||
34 | eProfileClass ScLcms2ColorProfileImpl::deviceClass() const |
||
35 | { |
||
36 | if (m_profileHandle) |
||
37 | return ScLcms2ColorMgmtEngineImpl::translateLcmsProfileClass( cmsGetDeviceClass(m_profileHandle) ); |
||
38 | return Class_Unknown; |
||
39 | } |
||
40 | |||
41 | QString ScLcms2ColorProfileImpl::productDescription() const |
||
42 | { |
||
43 | if (m_productDescription.isEmpty()) |
||
44 | { |
||
45 | if (m_profileHandle) |
||
46 | { |
||
47 | cmsUInt32Number descSize = cmsGetProfileInfo(m_profileHandle, cmsInfoDescription, "en", "US", NULL, 0); |
||
48 | if (descSize > 0) |
||
49 | { |
||
50 | wchar_t* descData = (wchar_t*) malloc(descSize + sizeof(wchar_t)); |
||
51 | descSize = cmsGetProfileInfo(m_profileHandle, cmsInfoDescription, "en", "US", descData, descSize); |
||
52 | if (descSize > 0) |
||
53 | { |
||
54 | if (sizeof(wchar_t) == sizeof(QChar)) { |
||
55 | m_productDescription = QString::fromUtf16((ushort *) descData, descSize / sizeof(wchar_t)); |
||
56 | } else { |
||
57 | m_productDescription = QString::fromUcs4((uint *) descData, descSize / sizeof(wchar_t)); |
||
58 | } |
||
59 | free(descData); |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | return m_productDescription; |
||
65 | } |
||
66 | |||
67 | void ScLcms2ColorProfileImpl::closeProfile(void) |
||
68 | { |
||
69 | if (m_profileHandle) |
||
70 | { |
||
71 | cmsCloseProfile(m_profileHandle); |
||
72 | m_profileHandle = NULL; |
||
73 | } |
||
74 | } |