[haiku-development] Re: Alpha/Transparency

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 6 Jul 2016 07:16:46 +0200

The alpha channel is used only in B_RGBA32 bitmap (not in B_RGB32 where
the byte is unused). Depdending on the drawing mode, various things can
happen:

- In B_OP_ALPHA: the alpha channel is handled according to the blending
  mode set with SetBlendingMode.
- In other modes: the alpha channel is handled with the same algorithm
  as the color channels. For example, with B_OP_COPY, the alpha value
  for each pixel is copied to the destination.

These are the same for Haiku and BeOS.

In Haiku, there are also some improvements:
- ClipToPicture now uses the alpha channel of the given picture, making
  it possible to clip to a partially opaque picture, or clip to an
  antialiased shape. In BeOS, any nonzero pixel is considered to be
  fully opaque (IOW, the picture was rendered to an 1-bit bitmap for
  masking). Additionally we have helper methods ClipToShape, ClipToRect,
  ClipToInverseShape, ClipToInverseRect (accepting a BShape and a BRect
  respectively), also with alpha clipping support. This also plays
  nicely with transforms, so even a rectangle clipping can have
  antialiased edges (because it was rotated or the edges are not on
  pixel boundaries).
- A new feature in Haiku (introduced recently) is
  BView::BeginLayer/EndLayer, which allows to perform a set of
  operations, then put the end result onto the view while applying a
  global alpha modifier to it.

-- 
Adrien.

Other related posts: