Assuming that the second bitmap already has the transparency set by
virtue of it being there in the original image file: Create a new
bitmap with wx.EmptyBitmap, and select it into wx.MemoryDC. Then do a
DrawBitmap with bitmapA and a DrawBitmap with bitmapB, making sure you
pass True for the transparent parameter. Then del the dc and the new
bitmap will now be a combination of the two originals.
--
Robin Dunn
Software Craftsman
http://wxPython.org
Somebody familiar with numpy could probably give you three lines of code
to transmorgify your triplets into a numpy array of RGBA data. But
numpy is still mostly magic for me so I'll just point you to the
MakeBitmapRGBpA function in BitmapFromBuffer.py in the demo. Notice how
it is making a separate buffer for the alpha channel values? You should
be able to do the same thing to create a bitmap with alpha using your
existing RGB values.
challenge accepted:
import numpy as np
def MakeBitmapRGBAnumpy(self, width, height, RGBdata, alpha=255):
# Make an RGBA bitmap using RGB bytes
# passed in as a string or other buffer object.
# it should be width*height*3 bytes long.
# The alpha channel is added with value provided
# create the empty array
rgba = np.empty((width, height, 4), dtype=np.uint8)
#make an array from the input rgb buffer
rgb = np.frombuffer()
# copy the
rgba[:,:,:3] = rbg
rgba[:,:,3] = alpha
return = wx.wx.BitmapFromBufferRGBA(width, height, rgba)
--
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