[haiku-development] Re: Hello, and a BBitmap question.

  • From: "François Revol" <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 24 May 2008 14:18:49 +0200 CEST

> > For C# users, this is done using Control.DrawToBitmap() followed by
> > Graphics.DrawImage() methods. Is this possible in Haiku?
>
> nicest in the BBitmap class, I can add such a call. For the time
> being, you
> should do something like this:
>
> void
> DrawViewAndChildren(BView* view, BRect updateRect)

Hmm it depends where the BControls you want to draw are...

That code supposes you create the BControls yourself and do bm->
AddChild() on them.

Are they already part of a BWindow hierarchy ?
If so you cannot do that.
Either temporarily remove them from the window they are in, attach them
to the bitmap, draw, and put them back to the window, or use BPicture,
like in Sudoku:
http://dev.haiku-os.org/browser/haiku/trunk/src/apps/sudoku/SudokuView.cpp#L412

You first force a draw on a BPicture object, without having to detach
the object (means you don't reset anything it might have changed), then
you draw the picture on a BView attached on a BPicture.

François.

Other related posts: