28#include <tqtextstream.h>
33#include "kis_profile.h"
34#include "kis_global.h"
36#include "ksharedptr.h"
42KisProfile::KisProfile(TQByteArray rawData)
44 m_filename( TQString() ),
46 m_suitableForOutput(false)
48 m_profile = cmsOpenProfileFromMem(rawData.data(), (DWORD)rawData.size());
52KisProfile::KisProfile(
const TQString& file)
55 m_suitableForOutput( false )
59KisProfile::KisProfile(
const cmsHPROFILE profile)
61 m_filename( TQString() ),
67 _cmsSaveProfileToMem(m_profile, 0, &bytesNeeded);
68 if(m_rawData.resize(bytesNeeded))
70 _cmsSaveProfileToMem(m_profile, m_rawData.data(), &bytesNeeded);
71 cmsHPROFILE newprofile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD) bytesNeeded);
72 cmsCloseProfile(m_profile);
73 m_profile = newprofile;
81KisProfile::~KisProfile()
83 cmsCloseProfile(m_profile);
87bool KisProfile::load()
89 TQFile file(m_filename);
90 file.open(IO_ReadOnly);
91 m_rawData = file.readAll();
92 m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size());
96 kdWarning() <<
"Failed to load profile from " << m_filename << endl;
103bool KisProfile::init()
106 m_colorSpaceSignature = cmsGetColorSpace(m_profile);
107 m_deviceClass = cmsGetDeviceClass(m_profile);
108 m_productName = cmsTakeProductName(m_profile);
109 m_productDescription = cmsTakeProductDesc(m_profile);
110 m_productInfo = cmsTakeProductInfo(m_profile);
119 cmsCIEXYZTRIPLE Primaries;
121 if (cmsTakeColorants(&Primaries, m_profile))
123 m_suitableForOutput =
true;
130 cmsCloseProfile(m_profile);
139cmsHPROFILE KisProfile::profile()
143 TQFile file(m_filename);
144 file.open(IO_ReadOnly);
145 m_rawData = file.readAll();
146 m_profile = cmsOpenProfileFromMem(m_rawData.data(), (DWORD)m_rawData.size());
153bool KisProfile::save()
158KisAnnotationSP KisProfile::annotation()
const
162 if (!m_rawData.isEmpty())
163 return new KisAnnotation(
"icc", productName(), m_rawData);
168KisProfile * KisProfile::getScreenProfile (
int screen)
175 unsigned long nitems;
176 unsigned long bytes_after;
179 static Atom icc_atom = XInternAtom( tqt_xdisplay(),
"_ICC_PROFILE", False );
181 if ( XGetWindowProperty ( tqt_xdisplay(),
182 tqt_xrootwin( screen ),
192 (
unsigned char **) &str)
195 TQByteArray bytes (nitems);
196 bytes.assign((
char*)str, (TQ_UINT32)nitems);
198 return new KisProfile(bytes);