{
public:
wxBitmap() {}
+ wxBitmap(const wxIDirectFBSurfacePtr& surface) { Create(surface); }
wxBitmap(int width, int height, int depth = -1);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
bool operator==(const wxBitmap& bmp) const;
bool operator!=(const wxBitmap& bmp) const { return !(*this == bmp); }
+ bool Create(const wxIDirectFBSurfacePtr& surface);
bool Create(int width, int height, int depth = -1);
virtual int GetHeight() const;
Create(width, height, depth);
}
+bool wxBitmap::Create(const wxIDirectFBSurfacePtr& surface)
+{
+ UnRef();
+
+ wxCHECK_MSG( surface, false, _T("invalid surface") );
+
+ m_refData = new wxBitmapRefData();
+ M_BITMAP->m_surface = surface;
+ return true;
+}
+
bool wxBitmap::Create(int width, int height, int depth)
{
UnRef();
desc.width = width;
desc.height = height;
- wxIDirectFBSurfacePtr surface(wxIDirectFB::Get()->CreateSurface(&desc));
- if ( !surface )
- return false;
-
- m_refData = new wxBitmapRefData();
- M_BITMAP->m_surface = surface;
-
- return true;
+ return Create(wxIDirectFB::Get()->CreateSurface(&desc));
}
#warning "FIXME: move this to common code"
wxNullBitmap,
wxT("invalid bitmap or bitmap region") );
+ // NB: DirectFB subsurfaces share the same pixels buffer, so we must
+ // clone the obtained subsurface
+ DFBRectangle r = { rect.x, rect.y, rect.width, rect.height };
+ return wxBitmap(M_BITMAP->m_surface->GetSubSurface(&r)->Clone());
}
#warning "to common code"