#15371 closed defect (fixed)

Loading wxBitmap from resource secretly sets incorrect mask

Reported by: hikeb Owned by:
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

When loading bitmap from resource:

wxBitmap bitmap("foo", wxBITMAP_TYPE_BMP_RESOURCE);

wxBMPResourceHandler::LoadFile, in line 386 of gdiimage.cpp, will set predefined (randomly selected?) mask:

// use 0xc0c0c0 as transparent colour by default
bitmap->SetMask(new wxMask(*bitmap, *wxLIGHT_GREY));

In most cases this will result in pixel artifacts where bitmap pixel color matches mask color. For unaware user it's difficult to figure out source of the problem, it's not stated anywhere that I could find.

Deleting mask afeter loading bitmap solves it:

bitmap.SetMask(nullptr);

Change History (1)

comment:1 Changed 17 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74641]) Document light grey colour handling in wxMSW wxBitmap::LoadFile().

For historical/compatibility reasons we handle this colour as transparent in
wxMSW when loading the bitmaps from resources, but this is rather not obvious
for the new users, so document it and provide a way of compensating for this
in the documentation as well.

Closes #15371.

Note: See TracTickets for help on using tickets.