57 pdfium::span<
const uint8_t> span) {
58 ScopedCmsProfile srcProfile(cmsOpenProfileFromMem(
59 span.data(), pdfium::base::checked_cast<cmsUInt32Number>(span.size())));
63 ScopedCmsProfile dstProfile(cmsCreate_sRGBProfile());
67 cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile.get());
68 uint32_t nSrcComponents = cmsChannelsOf(srcCS);
77 if (srcCS == cmsSigLabData) {
79 COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0);
83 COLORSPACE_SH(PT_ANY) | CHANNELS_SH(nSrcComponents) | BYTES_SH(1);
86 bNormal = srcCS == cmsSigGrayData || srcCS == cmsSigRgbData ||
87 srcCS == cmsSigCmykData;
89 cmsColorSpaceSignature dstCS = cmsGetColorSpace(dstProfile.get());
90 if (!Check3Components(dstCS))
93 cmsHTRANSFORM hTransform =
nullptr;
97 cmsCreateTransform(srcProfile.get(), srcFormat, dstProfile.get(),
98 TYPE_BGR_8, INTENT_PERCEPTUAL, 0);
103 NOTREACHED_NORETURN();
111 return pdfium::WrapUnique(
112 new IccTransform(hTransform, nSrcComponents, bLab, bNormal));
116 pdfium::span<
float> pDestValues) {
123 DataVector<
double> inputs(std::max<size_t>(pSrcValues.size(), 16));
124 for (uint32_t i = 0; i < pSrcValues.size(); ++i)
125 inputs[i] = pSrcValues[i];
126 cmsDoTransform(m_hTransform, inputs.data(), output, 1);
128 DataVector<uint8_t> inputs(std::max<size_t>(pSrcValues.size(), 16));
129 for (size_t i = 0; i < pSrcValues.size(); ++i) {
130 inputs[i] = std::clamp(
static_cast<
int>(pSrcValues[i] * 255.0f), 0, 255);
132 cmsDoTransform(m_hTransform, inputs.data(), output, 1);
134 pDestValues[0] = output[2] / 255.0f;
135 pDestValues[1] = output[1] / 255.0f;
136 pDestValues[2] = output[0] / 255.0f;