Hi, On 2010-01-29 at 17:06:08 [+0100], Sevcsik András <sevcsik@xxxxxxxxx> wrote: > Few days ago I started to experiment with the Haiku API, and I have two > questions: > > How can I set a BBitmap object to have transparent background? I loaded a > png to a BBitmap, and set it as background of a BView, but background > remains black. > Here's my code: > > bitmap = new BBitmap(BTranslationUtils::GetBitmapFile(PATH_DND_ICON)); You are leaking the bitmap returned by GetBitmapFile(). This should be just bitmap = BTranslationUtils::GetBitmapFile(PATH_DND_ICON); > fIcon = new BView(BRect(0, 0, 32, 32), "fIcon", B_FOLLOW_LEFT | > B_FOLLOW_V_CENTER, 0); > fIcon->SetViewBitmap(bitmap, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0); > fIcon->SetViewColor(0, 0, 0, 0); > fIcon->SetDrawingMode(B_OP_ALPHA); > fIcon->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); > > I tried other drawing and blending modes, but they didn't work. Background bitmaps cannot be transparent. Usually, what you want to achieve with regards to transparency is possible, just tell us what you are trying to do. If you want to install an icon into the Deskbar, just follow these steps: * Set the view color to be the same color as the parent's view color. If that color equals B_TRANSPARENT_COLOR, use the LowColor() instead (still for SetViewColor()). * Remember a pointer to the bitmap (don't use SetViewBitmap() at all) and draw the bitmap in Draw(). You should be able to use the drawing mode setup as you tried above, but I believe B_OP_OVER will work as well. > My other question is that can deskbar tray icons receive drag-n-drop > messages? Yes. These are BViews and by default, dropped messages appear in the drop target BView::MessageReceived() first. If they don't get handled there, the next handler gets a chance to look at the message, walking up the view hierarchy until arriving at the BWindow. Best regards, -Stephan