36 template<
class ImageType>
37 void ApplyICCProfile(
ImageType& image,
const vigra::ImageImportInfo::ICCProfile& iccProfile,
const cmsUInt32Number imageFormat)
40 typedef typename vigra::NumericTraits<typename ImageType::value_type>::isScalar is_scalar;
41 const bool isGrayscale(is_scalar().asBool);
43 cmsHPROFILE inputICC = NULL;
44 if (!iccProfile.empty())
46 inputICC = cmsOpenProfileFromMem(iccProfile.data(), iccProfile.size());
53 if (cmsGetColorSpace(inputICC) != cmsSigGrayData)
55 cmsCloseProfile(inputICC);
62 if (cmsGetColorSpace(inputICC) != cmsSigRgbData)
64 cmsCloseProfile(inputICC);
76 cmsHPROFILE outputICC;
80 cmsToneCurve* Curve = cmsBuildGamma(NULL, 2.2);
85 outputICC = cmsCreateGrayProfile(cmsD50_xyY(), Curve);
86 cmsFreeToneCurve(Curve);
91 outputICC = cmsCreate_sRGBProfile();
94 cmsHTRANSFORM transform = cmsCreateTransform(inputICC, imageFormat, outputICC, imageFormat,
95 INTENT_PERCEPTUAL, cmsFLAGS_BLACKPOINTCOMPENSATION);
96 cmsDoTransform(transform, image.begin(), image.begin(), image.width()*image.height());
98 cmsDeleteTransform(transform);
99 cmsCloseProfile(inputICC);
100 cmsCloseProfile(outputICC);
vigra::FRGBImage ImageType
void ApplyICCProfile(ImageType &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsUInt32Number imageFormat)
converts given image with iccProfile to sRGB/gray space, need to give pixel type in lcms2 format work...