I have a bitmap with a transparent part. This bitmap is painted multiple times in the frame. How can i use the transparent part of the bitmap to build a shape for the window. I’ve attached a sample that should demonstrate what i want to achieve. The sample uses given values for the sahpe, but my final code doesn’t know them.
I have a bitmap with a transparent part. This bitmap is painted multiple times in the frame. How can i use the transparent part of the bitmap to build a shape for the window. I’ve attached a sample that should demonstrate what i want to achieve. The sample uses given values for the sahpe, but my final code doesn’t know them.
no, i want a wx.Frame() that has no border and no background (like totally transparent), but only the frame. Buttons and pictures that i place inside should be fully visible. From my reading this is done with wx.frame.SetShape(wx.RegionFromBitmap(bmp)). The bmp is a black/white bitmap. The black part will be the transparent part of the frame (shape). For buttons i can easily get the position and size and paint a white rectangle on black ground. But the picture is my problem.
I have this:
And i want that:
What in the initial picture is transparent should be black, all other colours should be white.
Do you actually need a circle? or that a simple example? If circle, then
you can easily do that by makign a black rectangle and drawing a white
circle on it with a wx.MemoryDC.
But I suspect that you have an "arbitrary" image.
wxBitmap has essentiually no functionality, but wxImage does have some
basic Image processing -- maybe:
wxImage.Replace() can help.
Or, for more robust functionality, use the PIL or numpy. -- you can convert
to/from PIL images or numpy arrays pretty efficiently:
On Mon, Sep 11, 2017 at 10:18 AM, 'Torsten' via wxPython-users < wxpython-users@googlegroups.com> wrote:
no, i want a wx.Frame() that has no border and no background (like
totally transparent), but only the frame. Buttons and pictures that i place
inside should be fully visible. From my reading this is done with
wx.frame.SetShape(wx.RegionFromBitmap(bmp)). The bmp is a black/white
bitmap. The black part will be the transparent part of the frame (shape).
For buttons i can easily get the position and size and paint a white
rectangle on black ground. But the picture is my problem.
I have this:
And i want that:
What in the initial picture is transparent should be black, all other
colours should be white.
--
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
IIUC, one approach that comes to mind is to get the region from the original bitmap, create a new bitmap of the correct size and set it into a MemoryDC. Then clear the DC with a black brush, then do SetDeviceClippingRegion with the original bitmap’s transparent region, and then clear the DC with white.
If you need to combine multiple source bitmaps and get the remaining transparent space as a region, then another approach would be to fill a target bitmap & MemoryDC with a color you know is not in any of the sources, draw the sources to the bitmap, and then use SetMaskColour to set the target bitmap’s mask to include every pixel with that colour. Then you can use that bitmap to extract the region to be used to set the frame’s shape.
···
On Monday, September 11, 2017 at 10:18:45 AM UTC-7, Torsten wrote:
Hello Rufus,
no, i want a wx.Frame() that has no border and no background (like totally transparent), but only the frame. Buttons and pictures that i place inside should be fully visible. From my reading this is done with wx.frame.SetShape(wx.RegionFromBitmap(bmp)). The bmp is a black/white bitmap. The black part will be the transparent part of the frame (shape). For buttons i can easily get the position and size and paint a white rectangle on black ground. But the picture is my problem.
What in the initial picture is transparent should be black, all other colours should be white.
no, i want a wx.Frame() that has no border and no background (like totally transparent), but only the frame. Buttons and pictures that i place inside should be fully visible. From my reading this is done with wx.frame.SetShape(wx.RegionFromBitmap(bmp)). The bmp is a black/white bitmap. The black part will be the transparent part of the frame (shape). For buttons i can easily get the position and size and paint a white rectangle on black ground. But the picture is my problem.
What in the initial picture is transparent should be black, all other colours should be white.
I was curious about this technique, because Iiked the effect, even in your demo.
It looks like numpy (found by Google, not by experience) might have functions you could use: