Changeset View
Changeset View
Standalone View
Standalone View
lib/cms/cmsprofile.cpp
Context not available. | |||||
43 | #include <lcms2.h> | 43 | #include <lcms2.h> | ||
---|---|---|---|---|---|
44 | 44 | | |||
45 | // Exiv2 | 45 | // Exiv2 | ||
46 | #include <exiv2/exiv2.hpp> | 46 | #include <exiv2imageloader.h> | ||
47 | 47 | | |||
48 | // X11 | 48 | // X11 | ||
49 | #ifdef HAVE_X11 | 49 | #ifdef HAVE_X11 | ||
Context not available. | |||||
157 | return ptr; | 157 | return ptr; | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | Profile::Ptr Profile::loadFromExiv2Image(const Exiv2::Image* image) | 160 | Profile::Ptr Profile::loadFromExiv2Image(const Exiv2ImageLoader& exiv) | ||
161 | { | 161 | { | ||
162 | Profile::Ptr ptr; | 162 | Profile::Ptr ptr; | ||
163 | cmsHPROFILE hProfile = nullptr; | 163 | cmsHPROFILE hProfile = nullptr; | ||
164 | 164 | | |||
165 | const Exiv2::ExifData& exifData = image->exifData(); | 165 | QByteArray profData = exiv.interColorProfile(); | ||
166 | Exiv2::ExifKey key("Exif.Image.InterColorProfile"); | 166 | if(!profData.isEmpty()) { | ||
167 | Exiv2::ExifData::const_iterator it = exifData.findKey(key); | 167 | hProfile = cmsOpenProfileFromMem(profData.data(), profData.size()); | ||
168 | if (it == exifData.end()) { | | |||
169 | LOG("No profile found"); | | |||
170 | return ptr; | | |||
171 | } | | |||
172 | int size = it->size(); | | |||
173 | LOG("size:" << size); | | |||
174 | | ||||
175 | QByteArray data; | | |||
176 | data.resize(size); | | |||
177 | it->copy(reinterpret_cast<Exiv2::byte*>(data.data()), Exiv2::invalidByteOrder); | | |||
178 | hProfile = cmsOpenProfileFromMem(data, size); | | |||
179 | 168 | | |||
180 | if (hProfile) { | 169 | if (hProfile) { | ||
181 | ptr = new Profile(hProfile); | 170 | ptr = new Profile(hProfile); | ||
171 | } | ||||
182 | } | 172 | } | ||
183 | return ptr; | 173 | return ptr; | ||
184 | } | 174 | } | ||
Context not available. |