Changeset 71174 in webkit


Ignore:
Timestamp:
Nov 2, 2010 3:01:32 PM (13 years ago)
Author:
abarth@webkit.org
Message:

2010-11-02 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

JPEG decoders should understand color profiles
https://bugs.webkit.org/show_bug.cgi?id=48819

This patch is currently a no-op because no one defines USE(ICCJPEG).
We'll enable this for Chromium Mac once we have ICCJPEG landed in
Chromium's third_party directory.

  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp: (WebCore::readColorProfile): (WebCore::JPEGImageReader::JPEGImageReader): (WebCore::JPEGImageReader::decode): (WebCore::JPEGImageDecoder::outputScanlines):
  • platform/image-decoders/jpeg/JPEGImageDecoder.h: (WebCore::JPEGImageDecoder::setColorProfile):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71170 r71174  
     12010-11-02  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        JPEG decoders should understand color profiles
     6        https://bugs.webkit.org/show_bug.cgi?id=48819
     7
     8        This patch is currently a no-op because no one defines USE(ICCJPEG).
     9        We'll enable this for Chromium Mac once we have ICCJPEG landed in
     10        Chromium's third_party directory.
     11
     12        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
     13        (WebCore::readColorProfile):
     14        (WebCore::JPEGImageReader::JPEGImageReader):
     15        (WebCore::JPEGImageReader::decode):
     16        (WebCore::JPEGImageDecoder::outputScanlines):
     17        * platform/image-decoders/jpeg/JPEGImageDecoder.h:
     18        (WebCore::JPEGImageDecoder::setColorProfile):
     19
    1202010-11-02  Mihai Parparita  <mihaip@chromium.org>
    221
  • trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r71162 r71174  
    5252
    5353extern "C" {
     54
    5455#include "jpeglib.h"
     56
     57#if USE(ICCJPEG)
     58#include "iccjpeg.h"
     59#endif
     60
    5561}
    5662
     
    8692    JPEGImageReader* decoder;
    8793};
     94
     95static ColorProfile readColorProfile(jpeg_decompress_struct* info)
     96{
     97#if USE(ICCJPEG)
     98    JOCTET* profile;
     99    unsigned int profileLength;
     100
     101    if (!read_icc_profile(info, &profile, &profileLength))
     102        return ColorProfile();
     103
     104    ColorProfile colorProfile;
     105    colorProfile.append(reinterpret_cast<char*>(profile), profileLength);
     106    free(profile);
     107    return colorProfile;
     108#else
     109    return ColorProfile();
     110#endif
     111}
    88112
    89113class JPEGImageReader
     
    124148        src->pub.term_source = term_source;
    125149        src->decoder = this;
     150
     151        // Enable these markers for the ICC color profile.
     152        // Apparently there are 16 of these markers.  I don't see anywhere in the header with this constant.
     153        for (unsigned i = 0; i < 0xF; ++i)
     154            jpeg_save_markers(&m_info, JPEG_APP0 + i, 0xFFFF);
    126155    }
    127156
     
    213242                return false;
    214243
     244            m_decoder->setColorProfile(readColorProfile(info()));             
     245
    215246            if (m_decodingSizeOnly) {
    216247                // We can stop here.  Reduce our buffer length and available
     
    422453        buffer.setStatus(RGBA32Buffer::FramePartial);
    423454        buffer.setHasAlpha(false);
     455        buffer.setColorProfile(m_colorProfile);
    424456
    425457        // For JPEGs, the frame always fills the entire image.
  • trunk/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h

    r71162 r71174  
    5555        void jpegComplete();
    5656
     57        void setColorProfile(const ColorProfile& colorProfile) { m_colorProfile = colorProfile; }
     58
    5759    private:
    5860        // Decodes the image.  If |onlySize| is true, stops decoding after
Note: See TracChangeset for help on using the changeset viewer.