How to save BBitmap to image file

Can anyone please post code snippet for saving BBitmap to image file.

The 3rdparty-dev mailing list would be an excellent place to ask, as more coders follow the mailing list (as opposed to the forums).

http://www.freelists.org/list/haiku-3rdparty-dev

Haven’t done it, but BBitmap::Bits() is the data, right? So with that and BitsLength(), it should be smooth sailing from there, assuming you can manage to open a file, write to it and close it.