Correct delta-RLE bitmap background colour
Use black instead of the first palette colour for the implicit background for RLE bitmaps for consistency with Windows itself. Closes #23599.
This commit is contained in:
parent
4c94d5d1e5
commit
b473163da2
3 changed files with 9 additions and 18 deletions
|
|
@ -546,7 +546,13 @@ bool LoadBMPData(wxImage * image, const BMPDesc& desc,
|
|||
|
||||
// destroy existing here instead of:
|
||||
image->Destroy();
|
||||
image->Create(width, height);
|
||||
// RLE-compressed bitmaps do not necessarily specify every pixel explicitly,
|
||||
// as the delta escape sequence allows offsetting the current pixel position.
|
||||
// They have an implicit black background, which we get by clearing the image
|
||||
// on creation. Otherwise there is no point clearing, because we are going to
|
||||
// set every pixel from the source data anyway.
|
||||
bool clear = desc.comp == BI_RLE4 || desc.comp == BI_RLE8;
|
||||
image->Create(width, height, clear);
|
||||
|
||||
unsigned char *ptr = image->GetData();
|
||||
|
||||
|
|
@ -682,23 +688,6 @@ bool LoadBMPData(wxImage * image, const BMPDesc& desc,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reading the image data
|
||||
*/
|
||||
unsigned char *data = ptr;
|
||||
|
||||
/* set the whole image to the background color */
|
||||
if ( bpp < 16 && (desc.comp == BI_RLE4 || desc.comp == BI_RLE8) )
|
||||
{
|
||||
for (int i = 0; i < width * height; i++)
|
||||
{
|
||||
*ptr++ = cmap[0].r;
|
||||
*ptr++ = cmap[0].g;
|
||||
*ptr++ = cmap[0].b;
|
||||
}
|
||||
ptr = data;
|
||||
}
|
||||
|
||||
int linesize = ((width * bpp + 31) / 32) * 4;
|
||||
|
||||
// flag indicating if we have any not fully transparent alpha values: this
|
||||
|
|
|
|||
|
|
@ -1381,6 +1381,8 @@ TEST_CASE_METHOD(ImageHandlersInit, "wxImage::BMPLoadMethod", "[image][bmp]")
|
|||
CompareBMPImageLoad("image/horse_grey.bmp");
|
||||
CompareBMPImageLoad("image/horse_rle8.bmp");
|
||||
CompareBMPImageLoad("image/horse_rle4.bmp");
|
||||
CompareBMPImageLoad("image/rle8-delta-320x240.bmp");
|
||||
CompareBMPImageLoad("image/rle4-delta-320x240.bmp");
|
||||
}
|
||||
|
||||
#endif // CAN_LOAD_BITMAP_DIRECTLY
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Loading…
Add table
Add a link
Reference in a new issue