wxStaticBitmap holding 32-bit 0RGB bitmap is not displayed
|Reported by:||awi||Owned by:|
When wxStaticBitmap with 32-bit bitmap with alpha channel is created then internally there is also created a temporary copy of this bitmap with de-premultiplied RGB data (according to the STM_SETIMAGE requirements).
If on input there is provided 0RGB bitmap (in fact 32-bit with no real alpha) then the result of de-premultiplication is RGB (24-bit) only bitmap. A handle to this bitmap is next submitted to the control via STM_SETIMAGE and just after that the bitmap is destroyed. Because this is not a 32-bit bitmap STM_SETIMAGE handler doesn't create a "secret copy" of the bitmap and in effect nothing is displayed because the bitmap no longer exists.
Screenshot with sample output attached.
Generally, every bitmap submitted to STM_SETIMAGE must exist as long as the control exists. For 32-bit bitmaps STM_SETIMAGE creates a "secret copy" on its own, but for 24-bit it doesn't and this is a responsibility of caller to hold the bitmap.
Possible combinations of bitmaps are as follows: Input Temp. Secret bitmap bitmap copy ARGB ARGB Y need to manually destroy temp. bitmap and secret copy 0RGB RGB N need to manually destroy temp. bitmap RGB - N
In order to fix the issue there is necessary to hold the temporary bitmap over the control lifetime - patch attached.
Patch to reproduce the issue below:
old new 172 172 CreateStatusBar(2); 173 173 SetStatusText("Welcome to wxWidgets!"); 174 174 #endif // wxUSE_STATUSBAR 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 175 209 } 176 210