implemented wxBitmap::GetSubBitmap()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-09-14 14:36:12 +00:00
parent e195770310
commit 4562386dc5
2 changed files with 18 additions and 8 deletions

View File

@@ -63,6 +63,7 @@ class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
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);
@@ -76,6 +77,7 @@ public:
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;

View File

@@ -196,6 +196,17 @@ wxBitmap::wxBitmap(int width, int height, int depth)
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();
@@ -209,14 +220,7 @@ bool wxBitmap::Create(int width, int height, int depth)
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"
@@ -328,6 +332,10 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
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"