draw bitmap darker as if it had 50% transparency Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

draw bitmap darker as if it had 50% transparency

Post by mael15 »

i use DrawBitmap to draw some bitmaps (each with a wxMask) on a black background. is there any way to draw some of them darker, as if they had a 50% transparency? i do not want to repaint those with darker colors.
my goal is to highlight one of these bitmaps visually.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: draw bitmap darker as if it had 50% transparency

Post by doublemax »

If you're using wxGraphicsContext for drawing, wxGraphicsContext::BeginLayer() should work.
https://docs.wxwidgets.org/trunk/classw ... caa097ca1f

Under Windows, only the D2D renderer supports it, not the default GDI+ renderer.

Or you could use something like wxImage::ChangeBrightness() to change the bitmap data itself.
https://docs.wxwidgets.org/trunk/classw ... 0ebd2f666a
Use the source, Luke!
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: draw bitmap darker as if it had 50% transparency

Post by mael15 »

okay, thank you, then just painting with darker colors is the easier option for me.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: draw bitmap darker as if it had 50% transparency

Post by mael15 »

just in case someone has the same problem: wxBitmap::ConvertToDisabled(126) does the trick https://docs.wxwidgets.org/3.1.2/classw ... 54349bc22d
Post Reply