I have a PNG image which is partially transparent (let’s say, a rounded rectangle), so it includes its own alpha channel. I create the bitmap for the image like this:
This gives me what I want, but when I display it via creating a PaintDC and calling DrawBitmap, the edges of the rounded rectangle, which were nice and blurry in the original image, are horribly jagged, with no anti-aliasing. It looks this way on both Windows and Linux. What’s the proper way to do this?
I have a PNG image which is partially transparent (let's say, a rounded
rectangle), so it includes its own alpha channel. I create the bitmap for
the image like this:
says: "If *transparent* is true" -- but it indicates that the flag name is
"useMask" -- some testing is in order, but in any case you may need to set
a flag to True to get DrawBitmap to ue the Alpha channel.
-CHB
···
On Sun, Mar 9, 2014 at 7:32 PM, <exprelig@yahoo.com> wrote:
This gives me what I want, but when I display it via creating a PaintDC
and calling DrawBitmap, the edges of the rounded rectangle, which were nice
and blurry in the original image, are horribly jagged, with no
anti-aliasing. It looks this way on both Windows and Linux. What's the
proper way to do this?
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
You’re right, just loading it without the mask works in most situations. Not in my situation though; sorry, I should have specified that I’m trying to create a shaped window by using a PNG file as the shape. If you try to use a non-masked bitmap in a call to wx.RegionFromBitmap, it won’t work. And drawing a non-masked bitmap on top of a shaped window created using a masked copy of that bitmap doesn’t work either.
Long story short, I can’t figure out how to display a blurry PNG as a shaped window, or if it’s even possible. The code is attached, and it’s just a very simple modification of the ShapedWindow.py example.
I have a PNG image which is partially transparent (let’s say, a rounded rectangle), so it includes its own alpha channel. I create the bitmap for the image like this:
says: “If transparent is true” – but it indicates that the flag name is “useMask” – some testing is in order, but in any case you may need to set a flag to True to get DrawBitmap to ue the Alpha channel.
-CHB
This gives me what I want, but when I display it via creating a PaintDC and calling DrawBitmap, the edges of the rounded rectangle, which were nice and blurry in the original image, are horribly jagged, with no anti-aliasing. It looks this way on both Windows and Linux. What’s the proper way to do this?
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
You're right, just loading it without the mask works in most situations.
Not in my situation though; sorry, I should have specified that I'm
trying to create a shaped window by using a PNG file as the shape. If
you try to use a non-masked bitmap in a call to wx.RegionFromBitmap, it
won't work. And drawing a non-masked bitmap on top of a shaped window
created using a masked copy of that bitmap doesn't work either.
Long story short, I can't figure out how to display a blurry PNG as a
shaped window, or if it's even possible. The code is attached, and it's
just a very simple modification of the ShapedWindow.py example.
It's not possible currently. IIRC the native APIs needed for drawing a alpha transparent image on the screen are different than what are used for shaped windows.