[haiku-3rdparty-dev] Re: BPictureButton transparency ?

  • From: Michael Pfeiffer <michael.w.pfeiffer@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Mon, 27 Dec 2010 22:14:26 +0100

Am 27.12.2010 um 21:41 schrieb Tomas Wilhelmsson:

> Is it posible to make a BPictureButton Transparent somehow?

If the bitmap contains transparency information (alpha values)
setting the drawing and blending mode after BeginPicture(...)
is required IIRC.
view->SetDrawingMode(B_OP_ALPHA);
view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
or
to apply the alpha value from the high color to the bitmap
when it is drawn:
view->SetHighColor(0, 0, 0, alpha)
view->SetDrawingMode(B_OP_ALPHA);
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);

Not sure if a picture overwrites the drawing modes when it is draw; 
if it does you probably want to save and restore the state using
view->PushState() after BeginPicture and
view->PopState() before EndPicture.

> void BitmapToPicture(BView* view, BBitmap *bitmap, BPicture *pict) {
>       if (bitmap) {
>               view->BeginPicture(pict);
>               view->DrawBitmap(bitmap);
>               view->EndPicture();
>       }
> }

Bye,
Michael

Other related posts: