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

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

    // 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;

    ASSERT(colorProfile.isEmpty());
    if (!ignoreProfile)
        colorProfile.append(profileData, profileLength);
    free(profile);
#endif
}
Пример #2
0
static void getColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile, bool& sRGB)
{
#ifdef PNG_iCCP_SUPPORTED
    ASSERT(colorProfile.isEmpty());
    if (png_get_valid(png, info, PNG_INFO_sRGB)) {
        sRGB = true;
        return;
    }

    char* profileName;
    int compressionType;
#if (PNG_LIBPNG_VER < 10500)
    png_charp profile;
#else
    png_bytep profile;
#endif
    png_uint_32 profileLength;
    if (!png_get_iCCP(png, info, &profileName, &compressionType, &profile, &profileLength))
        return;

    // 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;

    if (!ignoreProfile)
        colorProfile.append(profileData, profileLength);
#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();

    // 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
    UNUSED_PARAM(info);
    return ColorProfile();
#endif
}
Пример #4
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
}
Пример #5
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();
}
Пример #6
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
}
Пример #7
0
void screenColorProfile(ColorProfile& toProfile)
{
    WebKit::WebVector<char> profile;
    WebKit::Platform::current()->screenColorProfile(&profile);
    toProfile.append(profile.data(), profile.size());
}