Opened 10 months ago

Closed 9 months ago

Last modified 7 months ago

#15876 closed defect (fixed)

Certain icons inside toolbars are empty, some html gets rendered wrong

Reported by: sodev Owned by:
Priority: normal Milestone: 3.0.1
Component: wxMSW Version: dev-latest
Keywords: wxdc icon bitmap transparent DDB alpha Cc: troelsk@…
Blocked By: Blocking: #14403, #14403, #14403
Patch: yes

Description

I am using svn revision 75608 and experience the problem that icons in certain toolbars are missing, the tool itself is present but no icon is shown.

I have compiled wxWidgets with Visual Studio 2013 (32 bit) and TDM-MinGW32 4.8.1 and run Windows 7 x64 and it happens in both cases. Originally i experienced this when compiling the recent CodeBlocks version, but it can also be seen in some wxWidgets samples.

For example the webview sample, the button descriptions like "Back", "Forward" are present but no icon is shown above them. The toolbar sample however works correct.

Another error occurs in the html/about sample, the about box is just plain white.

I tracked down the issue to the revision 75566, reverting this commit from the current revision 75608 fixes the mentioned issues. I assume the new transparency handling breaks certain drawing functions but i cannot investigate further.

Attachments (2)

toolbar-draw.patch download (777 bytes) - added by awi 9 months ago.
Fixed wxToolbar::Realize()
toolbar_buttons_alpha.diff download (602 bytes) - added by awi 9 months ago.
Fix to enable bitmap with transparency in toolbar

Download all attachments as: .zip

Change History (19)

comment:1 Changed 10 months ago by vadz

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

This should have been fixed by r75588, see #14403.

comment:2 Changed 10 months ago by sodev

But i am using r75608 and it is still broken?!

comment:3 Changed 10 months ago by vadz

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Oops, I misread this, sorry. Yes, I do see the problem here too, something is still wrong :-(

comment:4 Changed 10 months ago by vadz

  • Blocking 14403 added
  • Status changed from reopened to confirmed

Changed 9 months ago by awi

Fixed wxToolbar::Realize()

comment:5 Changed 9 months ago by awi

  • Keywords DDB alpha added
  • Patch set

These strange effects occur if there is a coincidence of three conditions:

  1. DDB bitmap without alpha channel selected into DC.
  2. Another bitmap with alpha channel is drawn using DrawBitmap function.
  3. In the code is used a GDI (physical) handle of the bitmap selected into DC (destination bitmap).

In this case destination bitmap (DDB) is converted to DIB before its blended with source bitmap (in AlphaBlt function, see #14403) and after that it is converted back to DDB. During this conversion GDI handle of the destination bitmap is changed (in fact the bitmap is recreated from temporary DIB).
If calling application has stored original handle of the bitmap for future use then after DrawBitmap call it is stored an invalid value.

E.g. wxToolBar::Realize() function is affected by this issue.

Application cannot assume that state of the destination bitmap (including its physical handle) will be preserved in DrawBitmap call.

Patch to fix wxToolbar attached.
Webview and Html/About samples should now work.

comment:6 Changed 9 months ago by awi

And one more note.
It's quite possible that tons of wx code rely on the assumption that bitmap handle is invariant of DrawBitamp calls. Generally, I think this is not the best practice but it can be also useful.
Technically it would be possible to preserve bitmap handle in internal transformations but in order to do so wxBitmap::UngetRawData function should be rewritten.
Now, old DDB is deleted and new one is created (if necessary) from temporary DIB. Instead, the existing DDB would be only updated.

comment:7 follow-up: Changed 9 months ago by troelsk

  • Cc troelsk@… added

toolbar-draw.patch works for me

comment:8 in reply to: ↑ 7 ; follow-up: Changed 9 months ago by johnr

Replying to troelsk:

toolbar-draw.patch works for me

Fixes things for me also for active icons. Toolbar icons don't look right using bmpDisabled=wxNullBitmap generated bitmaps when disabled. Nothing as good as OSX.

Changed 9 months ago by awi

Fix to enable bitmap with transparency in toolbar

comment:9 in reply to: ↑ 8 ; follow-up: Changed 9 months ago by awi

Replying to johnr:

Replying to troelsk:

toolbar-draw.patch works for me

Fixes things for me also for active icons. Toolbar icons don't look right using bmpDisabled=wxNullBitmap generated bitmaps when disabled. Nothing as good as OSX.

Disabled bitmaps can look better if bitmap with transparency would be enabled in the toolbar.
Patch attached.

comment:10 in reply to: ↑ 9 Changed 9 months ago by johnr

Replying to awi:

Disabled bitmaps can look better if bitmap with transparency would be enabled in the toolbar.
Patch attached.

Vast improvement, thanks.

comment:11 Changed 9 months ago by VZ

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

(In [75649]) Fix appearance of tools with alpha bitmaps in wxMSW wxToolBar.

Recent changes broke the handling of tools with alpha bitmaps as drawing them
on the global toolbar bitmap changes its underlying HBITMAP now, but the code
in wxToolBar didn't expect this.

Fix it by updating the HBITMAP used after every DrawBitmap() call, just in
case it changed (it doesn't cost anything to reset it if it did not).

Closes #15876.

comment:12 Changed 9 months ago by VZ

(In [75650]) Improve appearance of tools using bitmaps with alpha in wxMSW wxToolBar.

Use alpha in the combined toolbar bitmap if any of its tools has a bitmap
using alpha. This greatly improves the appearance of the automatically
generated disabled images for the tools with bitmaps using alpha.

See #15876.

comment:13 Changed 9 months ago by vadz

  • Milestone set to 3.0.1
  • Resolution changed from fixed to port to stable
  • Status changed from closed to portneeded

comment:14 Changed 9 months ago by VZ

  • Resolution changed from port to stable to fixed
  • Status changed from portneeded to closed

(In [75769]) Fix appearance of tools with alpha bitmaps in wxMSW wxToolBar.

Recent changes broke the handling of tools with alpha bitmaps as drawing them
on the global toolbar bitmap changes its underlying HBITMAP now, but the code
in wxToolBar didn't expect this.

Fix it by updating the HBITMAP used after every DrawBitmap() call, just in
case it changed (it doesn't cost anything to reset it if it did not).

Closes #15876.

comment:15 Changed 9 months ago by VZ

(In [75770]) Improve appearance of tools using bitmaps with alpha in wxMSW wxToolBar.

Use alpha in the combined toolbar bitmap if any of its tools has a bitmap
using alpha. This greatly improves the appearance of the automatically
generated disabled images for the tools with bitmaps using alpha.

See #15876.

comment:16 Changed 7 months ago by Aardappel

  • Blocking

(In #14403) Would like to note that the hack added to AlphaBlt unexpectedly made my app (treesheets) slow down to a crawl, so I had to comment it out. Not noticing any adverse effects yet.

comment:17 Changed 7 months ago by awi

  • Blocking
Note: See TracTickets for help on using tickets.