Fix loading colour palette from BMP file
Only BITMAPINFOHEADER data are explicitly read and processed so for a bitmap with BITMAPV4HEADER or BITMAPV5HEADER we have to forward stream position to the end of the actual header in order to start reading colour table from the right position. Closes #18634.
This commit is contained in:
committed by
Artur Wieczorek
parent
d583fb017b
commit
cccda9ef6b
@@ -1156,6 +1156,14 @@ bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream,
|
|||||||
|
|
||||||
ncolors = wxINT32_SWAP_ON_BE( (int)dbuf[0] );
|
ncolors = wxINT32_SWAP_ON_BE( (int)dbuf[0] );
|
||||||
res.Init(dbuf[2]/100, dbuf[3]/100);
|
res.Init(dbuf[2]/100, dbuf[3]/100);
|
||||||
|
|
||||||
|
// We've read BITMAPINFOHEADER data but for BITMAPV4HEADER or BITMAPV5HEADER
|
||||||
|
// we have to forward stream position to after the actual bitmap header.
|
||||||
|
if ( hdrSize > sizeof(BITMAPINFOHEADER) )
|
||||||
|
{
|
||||||
|
if ( stream.SeekI(hdrSize - sizeof(BITMAPINFOHEADER), wxFromCurrent) == wxInvalidOffset )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ncolors == 0)
|
if (ncolors == 0)
|
||||||
ncolors = 1 << bpp;
|
ncolors = 1 << bpp;
|
||||||
|
Reference in New Issue
Block a user