void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB) { clearColorTransform(); if (colorProfile.isEmpty() && !sRGB) return; qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); if (!deviceProfile) return; qcms_profile* inputProfile = 0; if (!colorProfile.isEmpty()) inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size()); else inputProfile = qcms_profile_sRGB(); if (!inputProfile) return; // We currently only support color profiles for RGB and RGBA images. ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); if (qcms_profile_match(inputProfile, deviceProfile)) { qcms_profile_release(inputProfile); return; } // FIXME: Don't force perceptual intent if the image profile contains an intent. qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL); qcms_profile_release(inputProfile); }
void WEBPImageDecoder::clear() { #if USE(QCMSLIB) clearColorTransform(); #endif WebPDemuxDelete(m_demux); m_demux = 0; clearDecoder(); }
~PNGImageReader() { #if USE(QCMSLIB) clearColorTransform(); #endif png_destroy_read_struct(m_png ? &m_png : 0, m_info ? &m_info : 0, 0); ASSERT(!m_png && !m_info); m_readOffset = 0; }
void close() { if (m_png && m_info) // This will zero the pointers. png_destroy_read_struct(&m_png, &m_info, 0); #if USE(QCMSLIB) clearColorTransform(); #endif m_readOffset = 0; }
bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) { clearColorTransform(); qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); if (!deviceProfile) return false; qcms_profile* inputProfile = qcms_profile_from_memory(data, size); if (!inputProfile) return false; // We currently only support color profiles for RGB profiled images. ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile)); // The input image pixels are RGBA format. qcms_data_type format = QCMS_DATA_RGBA_8; // FIXME: Don't force perceptual intent if the image profile contains an intent. m_transform = qcms_transform_create(inputProfile, format, deviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL); qcms_profile_release(inputProfile); return !!m_transform; }