Пример #1
0
static ColorProfile readColorProfile(jpeg_decompress_struct* info)
{
#if USE(ICCJPEG)
    JOCTET* profile;
    unsigned int profileLength;

    if (!read_icc_profile(info, &profile, &profileLength))
        return ColorProfile();

    // Only accept RGB color profiles from input class devices.
    bool ignoreProfile = false;
    char* profileData = reinterpret_cast<char*>(profile);
    if (profileLength < ImageDecoder::iccColorProfileHeaderLength)
        ignoreProfile = true;
    else if (!ImageDecoder::rgbColorProfile(profileData, profileLength))
        ignoreProfile = true;
    else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileLength))
        ignoreProfile = true;

    ColorProfile colorProfile;
    if (!ignoreProfile)
        colorProfile.append(profileData, profileLength);
    free(profile);
    return colorProfile;
#else
    return ColorProfile();
#endif
}
Пример #2
0
static ColorProfile readColorProfile(jpeg_decompress_struct* info)
{
#if USE(ICCJPEG)
    JOCTET* profile;
    unsigned int profileLength;

    if (!read_icc_profile(info, &profile, &profileLength))
        return ColorProfile();
    char* profileData = reinterpret_cast<char*>(profile);
    // Images with grayscale profiles get "upsampled" by libjpeg. If we use
    // their color profile, CoreGraphics will "upsample" them
    // again, resulting in horizontal distortions.
    if (profileLength >= 20 && !memcmp(&profileData[16], "GRAY", 4)) {
        free(profile);
        return ColorProfile();
    }

    ColorProfile colorProfile;
    colorProfile.append(profileData, profileLength);
    free(profile);
    return colorProfile;
#else
    return ColorProfile();
#endif
}
Пример #3
0
static ColorProfile readColorProfile(jpeg_decompress_struct* info)
{
#if USE(ICCJPEG)
    JOCTET* profile;
    unsigned int profileLength;

    if (!read_icc_profile(info, &profile, &profileLength))
        return ColorProfile();

    ColorProfile colorProfile;
    colorProfile.append(reinterpret_cast<char*>(profile), profileLength);
    free(profile);
    return colorProfile;
#else
    return ColorProfile();
#endif
}
Пример #4
0
static ColorProfile readColorProfile(png_structp png, png_infop info)
{
#ifdef PNG_iCCP_SUPPORTED
    char* profileName;
    int compressionType;
    char* profile;
    png_uint_32 profileLength;
    if (png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength)) {
        ColorProfile colorProfile;
        colorProfile.append(profile, profileLength);
        return colorProfile;
    }
#endif
    return ColorProfile();
}