Transparent raster images
Martin Schulze
joey at infodrom.org
Tue May 3 07:57:59 CEST 2005
Jonathan Coles wrote:
> 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.
Oh, I thought the one-bit transparency from GIF was supported as well.
> 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")
FWIW, this doesn't render the graphic transparent.
The WMS code currently has:
img, format = layer.GetMapImg(width, height, (xmin, ymin, xmax, ymax))
data = (width, height, (img, None, None))
renderer.draw_raster_data(layer, 0,0, data, format)
So basically it's doing what you proposed. However, no two layers are
rendered with transparent background but with solid background. I'm
attaching an image to "prove" that the Frida server indeed provides
transparent PNG files.
> 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
Which values does alpha_data need? Just True/1?
> 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.
Hmm. Thenks. Guess I'll have to wait until then then.
Regards,
Joey
--
MIME - broken solution for a broken design. -- Ralf Baechle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wms.png
Type: image/png
Size: 5968 bytes
Desc: not available
Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050503/26198330/wms.png
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)