Enable access to the native bitmap object wrapped by wxGraphicsBitmap
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
caf1a3aa68
commit
8b180bded6
@ -107,6 +107,7 @@ class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmap;
|
||||
//
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxGraphicsObjectRefData;
|
||||
class WXDLLIMPEXP_FWD_CORE wxGraphicsBitmapData;
|
||||
class WXDLLIMPEXP_FWD_CORE wxGraphicsMatrixData;
|
||||
class WXDLLIMPEXP_FWD_CORE wxGraphicsPathData;
|
||||
|
||||
@ -174,6 +175,13 @@ public:
|
||||
#if wxUSE_IMAGE
|
||||
wxImage ConvertToImage() const;
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
void* GetNativeBitmap() const;
|
||||
|
||||
const wxGraphicsBitmapData* GetBitmapData() const
|
||||
{ return (const wxGraphicsBitmapData*) GetRefData(); }
|
||||
wxGraphicsBitmapData* GetBitmapData()
|
||||
{ return (wxGraphicsBitmapData*) GetRefData(); }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGraphicsBitmap)
|
||||
|
@ -28,6 +28,18 @@ class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData
|
||||
wxGraphicsRenderer* m_renderer;
|
||||
} ;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsBitmapData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public :
|
||||
wxGraphicsBitmapData( wxGraphicsRenderer* renderer) :
|
||||
wxGraphicsObjectRefData(renderer) {}
|
||||
|
||||
virtual ~wxGraphicsBitmapData() {}
|
||||
|
||||
// returns the native representation
|
||||
virtual void * GetNativeBitmap() const = 0;
|
||||
} ;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public :
|
||||
|
@ -296,6 +296,14 @@ public:
|
||||
@since 2.9.3
|
||||
*/
|
||||
wxImage ConvertToImage() const;
|
||||
|
||||
/**
|
||||
Return the pointer to the native bitmap data. (CGImageRef for Core Graphics,
|
||||
cairo_surface_t for Cairo, Bitmap* for GDI+.)
|
||||
|
||||
@since 2.9.4
|
||||
*/
|
||||
void* GetNativeBitmap() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -524,6 +524,11 @@ void wxGraphicsGradientStops::Add(const wxGraphicsGradientStop& stop)
|
||||
}
|
||||
}
|
||||
|
||||
void * wxGraphicsBitmap::GetNativeBitmap() const
|
||||
{
|
||||
return GetBitmapData()->GetNativeBitmap();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxGraphicsContext Convenience Methods
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -323,7 +323,7 @@ private :
|
||||
cairo_font_weight_t m_weight;
|
||||
};
|
||||
|
||||
class wxCairoBitmapData : public wxGraphicsObjectRefData
|
||||
class wxCairoBitmapData : public wxGraphicsBitmapData
|
||||
{
|
||||
public:
|
||||
wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp );
|
||||
@ -335,6 +335,7 @@ public:
|
||||
|
||||
virtual cairo_surface_t* GetCairoSurface() { return m_surface; }
|
||||
virtual cairo_pattern_t* GetCairoPattern() { return m_pattern; }
|
||||
void* GetNativeBitmap() const { return (void*)m_surface; }
|
||||
virtual wxSize GetSize() { return wxSize(m_width, m_height); }
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
@ -1248,13 +1249,13 @@ void wxCairoBitmapData::InitSurface(cairo_format_t format, int stride)
|
||||
}
|
||||
|
||||
wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, cairo_surface_t* bitmap ) :
|
||||
wxGraphicsObjectRefData( renderer )
|
||||
wxGraphicsBitmapData( renderer )
|
||||
{
|
||||
m_surface = bitmap;
|
||||
m_pattern = cairo_pattern_create_for_surface(m_surface);
|
||||
}
|
||||
|
||||
wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ) : wxGraphicsObjectRefData( renderer )
|
||||
wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ) : wxGraphicsBitmapData( renderer )
|
||||
{
|
||||
wxCHECK_RET( bmp.IsOk(), wxT("Invalid bitmap in wxCairoContext::DrawBitmap"));
|
||||
|
||||
@ -1394,7 +1395,7 @@ inline unsigned char Unpremultiply(unsigned char alpha, unsigned char data)
|
||||
|
||||
wxCairoBitmapData::wxCairoBitmapData(wxGraphicsRenderer* renderer,
|
||||
const wxImage& image)
|
||||
: wxGraphicsObjectRefData(renderer)
|
||||
: wxGraphicsBitmapData(renderer)
|
||||
{
|
||||
const cairo_format_t bufferFormat = image.HasAlpha()
|
||||
? CAIRO_FORMAT_ARGB32
|
||||
|
@ -272,7 +272,7 @@ private:
|
||||
GraphicsPath* m_brushPath;
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGDIPlusBitmapData : public wxGraphicsObjectRefData
|
||||
class WXDLLIMPEXP_CORE wxGDIPlusBitmapData : public wxGraphicsBitmapData
|
||||
{
|
||||
public:
|
||||
wxGDIPlusBitmapData( wxGraphicsRenderer* renderer, Bitmap* bitmap );
|
||||
@ -280,6 +280,7 @@ public:
|
||||
~wxGDIPlusBitmapData ();
|
||||
|
||||
virtual Bitmap* GetGDIPlusBitmap() { return m_bitmap; }
|
||||
void* GetNativeBitmap() const { return (void*)m_bitmap; }
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
wxImage ConvertToImage() const;
|
||||
@ -943,13 +944,13 @@ wxGDIPlusFontData::~wxGDIPlusFontData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer, Bitmap* bitmap ) :
|
||||
wxGraphicsObjectRefData( renderer ), m_bitmap( bitmap )
|
||||
wxGraphicsBitmapData( renderer ), m_bitmap( bitmap )
|
||||
{
|
||||
m_helper = NULL;
|
||||
}
|
||||
|
||||
wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer,
|
||||
const wxBitmap &bmp) : wxGraphicsObjectRefData( renderer )
|
||||
const wxBitmap &bmp) : wxGraphicsBitmapData( renderer )
|
||||
{
|
||||
m_bitmap = NULL;
|
||||
m_helper = NULL;
|
||||
|
@ -969,13 +969,14 @@ wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
|
||||
#endif
|
||||
}
|
||||
|
||||
class wxMacCoreGraphicsBitmapData : public wxGraphicsObjectRefData
|
||||
class wxMacCoreGraphicsBitmapData : public wxGraphicsBitmapData
|
||||
{
|
||||
public:
|
||||
wxMacCoreGraphicsBitmapData( wxGraphicsRenderer* renderer, CGImageRef bitmap, bool monochrome );
|
||||
~wxMacCoreGraphicsBitmapData();
|
||||
|
||||
virtual CGImageRef GetBitmap() { return m_bitmap; }
|
||||
void* GetNativeBitmap() const { return (void*)m_bitmap; }
|
||||
bool IsMonochrome() { return m_monochrome; }
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
@ -990,7 +991,7 @@ private :
|
||||
bool m_monochrome;
|
||||
};
|
||||
|
||||
wxMacCoreGraphicsBitmapData::wxMacCoreGraphicsBitmapData( wxGraphicsRenderer* renderer, CGImageRef bitmap, bool monochrome ) : wxGraphicsObjectRefData( renderer ),
|
||||
wxMacCoreGraphicsBitmapData::wxMacCoreGraphicsBitmapData( wxGraphicsRenderer* renderer, CGImageRef bitmap, bool monochrome ) : wxGraphicsBitmapData( renderer ),
|
||||
m_bitmap(bitmap), m_monochrome(monochrome)
|
||||
{
|
||||
}
|
||||
@ -2245,7 +2246,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble
|
||||
return;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
wxMacCoreGraphicsBitmapData* refdata =static_cast<wxMacCoreGraphicsBitmapData*>(bmp.GetRefData());
|
||||
wxMacCoreGraphicsBitmapData* refdata = static_cast<wxMacCoreGraphicsBitmapData*>(bmp.GetRefData());
|
||||
CGImageRef image = refdata->GetBitmap();
|
||||
CGRect r = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h );
|
||||
if ( refdata->IsMonochrome() == 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user