Carsten Haitzler (The Rasterman)
raster at rasterman.com
Thu Jul 26 16:19:56 PDT 2007
On Fri, 27 Jul 2007 00:21:18 +0200 Juliusz Chroboczek
<Juliusz.Chroboczek at pps.jussieu.fr> babbled:
> >> How can you make part of an XImage transparent (true transparency - as
> >> in I can see something under the transparent parts) ?
> > You can't.
> > If you want to plot a "masked" image, you need a separate mask bitmap,
> > where 1 represents opaque and 0 represents transparent.
> > First, the mask needs to exist as a 1-bit Pixmap. You can then set
> > this as the clip mask using XSetClipMask() and XSetClipOrigin(). When
> > you draw the image (XPutImage), it will be masked against the clip
> > mask.
> And watch your X server collapse.
> If you use XSetClipMask, the bitmap will be converted to a set of
> spans, which will kill performance.
that depends on the mask complexity. if its a simple-ish outline you are fine.
(i.e no more than 2 spans per image line on average for example).
> Instead, you should be using the Render extension together with RGBA
and watch performance collapse too. xrender isn't a perfromance beast. you pay
for a read/modify/write cycle PER PIXEL. xputimage with a mask is a write cycle
only with no read latency from the destination involved (and good luck if its
accelerated - properly). also this will limit you to SANE uses only being 24bpp
- down to 16bpp and 8bpp this will just fall over as xrender needs to
up-convert to 24bpp - do the blend, then down-convert to destination depth (or
use colorspace specific blend handling). also this won't work on old xservers -
so you need a fallback for when you run on that nice old NCD terminal anyway -
so back to ximage + mask :)
main point is - xrender is not a silver bullet. it's a bed of roses - lots of
thorns too. it mostly depends on what kind of input data you are looking at and
your desired results and support. xrender is an option - if alpha blending is
really what you want/need. if your masks will be complex it might be an option
too. in the end unless you are creating toolkits - you probably want to use
existing toolkits/libraries to worry about this for you as people have written
them to abstract this problem away from you.
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster at rasterman.com
Tokyo, Japan (東京 日本)
More information about the xorg