Changeset 50677 in webkit


Ignore:
Timestamp:
Nov 9, 2009 12:32:38 PM (14 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

[wx] Fix handling of alpha channel when using wxWidgets 2.9: it was
simply ignored before resulting in transparent areas being black in PNG
images for example.

https://bugs.webkit.org/show_bug.cgi?id=30823

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50675 r50677  
     12009-11-09  Vadim Zeitlin  <vadim@wxwidgets.org>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        [wx] Fix handling of alpha channel when using wxWidgets 2.9: it was
     6        simply ignored before resulting in transparent areas being black in PNG
     7        images for example.
     8       
     9        https://bugs.webkit.org/show_bug.cgi?id=30823
     10
     11        * platform/image-decoders/wx/ImageDecoderWx.cpp:
     12        (WebCore::RGBA32Buffer::asNewNativeImage):
     13
    1142009-11-09  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    215
  • trunk/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp

    r47867 r50677  
    4141{
    4242    wxBitmap* bmp = new wxBitmap(width(), height(), 32);
    43     typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> WxPixelData;
    44     WxPixelData data(*bmp);
    45    
    46     // NB: It appears that the data is in BGRA format instead of RGBA format.
    47     // This code works properly on both ppc and intel, meaning the issue is
    48     // likely not an issue of byte order getting mixed up on different archs.
    49     const unsigned char* bytes = (const unsigned char*)m_bytes.data();
    50     int rowCounter = 0;
    51     long pixelCounter = 0;
    52     WxPixelData::Iterator p(data);
    53     WxPixelData::Iterator rowStart = p;
    54     for (size_t i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) {
    55         p.Red() = bytes[i+2];
    56         p.Green() = bytes[i+1];
    57         p.Blue() = bytes[i+0];
    58         p.Alpha() = bytes[i+3];
     43
     44    {
     45        typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> WxPixelData;
     46        WxPixelData data(*bmp);
    5947       
    60         p++;
     48        // NB: It appears that the data is in BGRA format instead of RGBA format.
     49        // This code works properly on both ppc and intel, meaning the issue is
     50        // likely not an issue of byte order getting mixed up on different archs.
     51        const unsigned char* bytes = (const unsigned char*)m_bytes.data();
     52        int rowCounter = 0;
     53        long pixelCounter = 0;
     54        WxPixelData::Iterator p(data);
     55        WxPixelData::Iterator rowStart = p;
     56        for (size_t i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) {
     57                p.Red() = bytes[i + 2];
     58                p.Green() = bytes[i + 1];
     59                p.Blue() = bytes[i + 0];
     60                p.Alpha() = bytes[i + 3];
     61           
     62            p++;
    6163
    62         pixelCounter++;
    63         if ((pixelCounter % width()) == 0) {
    64             rowCounter++;
    65             p = rowStart;
    66             p.MoveTo(data, 0, rowCounter);
     64            pixelCounter++;
     65            if ((pixelCounter % width()) == 0) {
     66                rowCounter++;
     67                p = rowStart;
     68                p.MoveTo(data, 0, rowCounter);
     69            }
    6770        }
    68     }
    6971#if !wxCHECK_VERSION(2,9,0)
    70     bmp->UseAlpha();
     72        bmp->UseAlpha();
    7173#endif
     74    } // ensure that WxPixelData is destroyed as it unlocks the bitmap data in
     75      // its dtor and we can't access it (notably in CreateBitmap() below)
     76      // before this is done
     77
    7278    ASSERT(bmp->IsOk());
    7379
Note: See TracChangeset for help on using the changeset viewer.