Transparent raster images
Jonathan Coles
jonathan.coles at gmail.com
Mon May 2 14:37:36 CEST 2005
2005/5/2, Martin Schulze <joey at infodrom.org>:
> Thuban.UI.renderer contains draw_raster_data() which seems to support
> an alpha channel and is supposed to support some sort of transparency.
>
> How is this supposed to work? In the WMS extension I can order the
> server to create a GIF or PNG image with a transparent background.
> I'd like to pass this information to the renderer, but don't know
> how. Any hint or links to explanations would be appreciated.
i just tested a hack which used a png image with transparency and it
worked. note that wxWidgets only supports transparency in png images.
use the following as an example for use where ever you are going to
call draw_raster_data().
# get the raw png data (replace this with your preferred method)
f = open("sample.png")
png_data = f.read(-1) # read whole file
# img_data is a tuple of [raw_image_data, mask_data, alpha_data]
# mask_data and alpha_data should be None because the alpha data is stored
# in the png data
img_data = [png_data, None, None]
# width and height are the dimensions of the image
data = (width, height, img_data)
self.draw_raster_data(layer, 0, 0, data, format="PNG")
adjusting the opacity of the layer when using a format other than
"RAW" will only work if alpha_data is not None. Since the alpha data
is stored in the png file the layer's opacity property will not
currently affect the drawn opacity. This is simple to fix. i will add
a patch soon.
in addition, i'm going to replace the layer parameter with just the
opacity level.
--jonathan
--
=====================================================================
Jonathan Coles http://www.jpcoles.com
jonathan at jpcoles.com
=====================================================================
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)