Allow creating wxGraphicsBitmap and wxGraphicsContext from wxImage.

Provide a way to use wxGraphicsContext to draw on wxImage.

This is implemented internally by drawing on wxGraphicsBitmap which can be now
also created from wxImage.

Add a test of the new functionality to the image sample.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69358 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-10-09 22:07:22 +00:00
parent 12493a5fb8
commit 0a470e5ea5
8 changed files with 439 additions and 8 deletions

View File

@@ -269,11 +269,11 @@ enum wxCompositionMode
Represents a bitmap.
The objects of this class are not created directly but only via
wxGraphicsContext or wxGraphicsRenderer CreateBitmap() and
CreateSubBitmap() methods. They can subsequently be used with
wxGraphicsContext::DrawBitmap(). The only other operation is testing for
the bitmap validity which can be performed using IsNull() method inherited
from the base class.
wxGraphicsContext or wxGraphicsRenderer CreateBitmap(),
CreateBitmapFromImage() or CreateSubBitmap() methods. They can subsequently
be used with wxGraphicsContext::DrawBitmap(). The only other operation is
testing for the bitmap validity which can be performed using IsNull()
method inherited from the base class.
*/
class wxGraphicsBitmap : public wxGraphicsObject
{
@@ -384,6 +384,19 @@ public:
*/
static wxGraphicsContext* Create(const wxEnhMetaFileDC& dc);
/**
Creates a wxGraphicsContext associated with a wxImage.
The image specifies the size of the context as well as whether alpha is
supported (if wxImage::HasAlpha()) or not and the initial contents of
the context. The @a image object must have a life time greater than
that of the new context as the context copies its contents back to the
image when it is destroyed.
@since 2.9.3
*/
static wxGraphicsContext* Create(wxImage& image);
/**
Clips drawings to the specified region.
*/
@@ -407,6 +420,18 @@ public:
*/
virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0;
/**
Creates wxGraphicsBitmap from an existing wxImage.
This method is more efficient than converting wxImage to wxBitmap first
and then calling CreateBitmap() but otherwise has the same effect.
Returns an invalid wxNullGraphicsBitmap on failure.
@since 2.9.3
*/
virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image);
/**
Extracts a sub-bitmap from an existing bitmap.
@@ -914,6 +939,18 @@ public:
*/
virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0;
/**
Creates wxGraphicsBitmap from an existing wxImage.
This method is more efficient than converting wxImage to wxBitmap first
and then calling CreateBitmap() but otherwise has the same effect.
Returns an invalid wxNullGraphicsBitmap on failure.
@since 2.9.3
*/
virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image) = 0;
/**
Creates wxGraphicsBitmap from a native bitmap handle.
@@ -951,6 +988,16 @@ public:
*/
virtual wxGraphicsContext* CreateContext(const wxEnhMetaFileDC& dc) = 0;
/**
Creates a wxGraphicsContext associated with a wxImage.
This function is used by wxContext::CreateFromImage() and is not
normally called directly.
@since 2.9.3
*/
static wxGraphicsContext* CreateContextFromImage(wxImage& image);
/**
Creates a native brush from a wxBrush.
*/