+ wxImage img(GetWidth(), GetHeight());
+ wxIDirectFBSurfacePtr src = M_BITMAP->m_surface;
+
+ if ( src->GetPixelFormat() == DSPF_RGB24 )
+ {
+ CopySurfaceToImage(src, img);
+ }
+ else
+ {
+ // wxBitmap uses different pixel format, so we have to use a temporary
+ // surface and blit to the bitmap via it:
+ wxIDirectFBSurfacePtr dst(CreateSurfaceForImage(img));
+
+ if ( !dst->SetBlittingFlags(DSBLIT_NOFX) )
+ return wxNullImage;
+ if ( !dst->Blit(src->GetRaw(), NULL, 0, 0) )
+ return wxNullImage;
+
+ CopySurfaceToImage(dst, img);
+ }
+
+ // FIXME: implement mask setting in the image
+ wxASSERT_MSG( GetMask() == NULL, _T("bitmap masks are ignored for now") );
+
+ return img;