[haiku-3rdparty-dev] Drawing into a BBitmap using a BView

  • From: "Matthew Allen" <fret@xxxxxxxxxxxx>
  • To: <haiku-3rdparty-dev@xxxxxxxxxxxxx>
  • Date: Wed, 12 Jun 2013 9:11:49 +1000

Hi,

In some cases my code creates a bitmap memory context (implemented as a BBitmap 
on Haiku) and draws into that usings it's own code, then it also needs to draw 
text into that BBitmap. I'm assuming the correct way to do that is to create a 
BView, and use BBitmap::AddChild to add that BView to the BBitmap, then use the 
BView to do your drawing?

Well I tried that and none of the calls into the BView's drawing functions show 
anything on the BBitmap. You can see my code here:

        
http://sourceforge.net/p/lgi/code/HEAD/tree/trunk/src/beos/Gdc2/GMemDC.cpp#l91

Search for "GMemDC::Create". You can see it creates a BBitmap (with the right 
flags), and then a BView. Then adds the BView to the BBitmap. Later on I go to 
draw on the BView here:

        
http://sourceforge.net/p/lgi/code/HEAD/tree/trunk/src/common/Gdc2/Font/GDisplayString.cpp

In the method GDisplayString::Draw, the BEOS section retreives the BView from 
the GMemDC, sets the High and Low color, then calls DrawString. This works fine 
if the window is attached to a BView or BWindow, but not a BBitmap.

Is this supported in Haiku? (I do seem to remember it working in r5).

Regards
--
Matthew Allen


Other related posts: