Ignore:
Timestamp:
Jan 24, 2012, 11:47:23 PM (14 years ago)
Author:
dmik
Message:

Align scanlines passed to GetDIBits on a LONG boundary.

This fixes crashes in CreateIconIndirect()/CreateIconFromResource()/LoadImage()
etc. See #58 for more info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/winicon.cpp

    r21916 r21951  
    163163    colortablesize = 0;
    164164
     165    // CreateDIBits expectes DWORD-aligned scan lines
     166    bmpXor.bmWidthBytes = (bmpXor.bmWidthBytes + 3) / 4 * 4;
     167    bmpAnd.bmWidthBytes = (bmpAnd.bmWidthBytes + 3) / 4 * 4;
     168
    165169    if(bmpXor.bmBitsPixel <= 8) {
    166170         colortablesize = sizeof(RGBQUAD)*(1<<bmpXor.bmBitsPixel);
     
    221225            //recalculate the mask bitmap size
    222226            GetObjectA( hbmMask, sizeof(bmpAnd), &bmpAnd );
    223             sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
     227            sizeAnd = bmpAnd.bmHeight * (bmpAnd.bmWidthBytes + 3) / 4 * 4;
    224228
    225229            //query the 1bpp bitmap data
     
    11601164    }
    11611165
     1166    // CreateDIBits expectes DWORD-aligned scan lines
     1167    bmpXor.bmWidthBytes = (bmpXor.bmWidthBytes + 3) / 4 * 4;
     1168    bmpAnd.bmWidthBytes = (bmpAnd.bmWidthBytes + 3) / 4 * 4;
     1169
    11621170    if(bmpXor.bmBitsPixel <= 8) {
    11631171         colortablesize = sizeof(RGBQUAD)*(1<<bmpXor.bmBitsPixel);
Note: See TracChangeset for help on using the changeset viewer.