subrect blit

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-10-29 19:43:25 +00:00
parent 2612a310cb
commit b2d123f142
2 changed files with 7 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ class WXDLLEXPORT wxWindowDC: public wxDC
wxWindow *GetWindow() const { return m_window; }
protected :
virtual void DoGetSize( int *width, int *height ) const;
virtual wxBitmap DoGetAsBitmap() const;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const;
wxWindow *m_window;
#if wxMAC_USE_CORE_GRAPHICS
bool m_release;

View File

@@ -133,7 +133,6 @@ wxWindowDC::wxWindowDC(wxWindow *window)
if ( cg == NULL )
{
SetGraphicsContext( wxGraphicsContext::Create( window ) ) ;
SetDeviceOrigin( x, y );
}
else
{
@@ -188,7 +187,7 @@ void wxWindowDC::DoGetSize( int* width, int* height ) const
#endif
}
wxBitmap wxWindowDC::DoGetAsBitmap() const
wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const
{
ControlRef handle = (ControlRef) m_window->GetHandle();
if ( !handle )
@@ -203,14 +202,17 @@ wxBitmap wxWindowDC::DoGetAsBitmap() const
HIViewCreateOffscreenImage( handle, 0, &rect, &image);
int width = rect.size.width;
int height = rect.size.height;
int width = subrect != NULL ? subrect->width : rect.size.width;
int height = subrect != NULL ? subrect->height : rect.size.height ;
bytesPerRow = ( ( width * 8 * 4 + 7 ) / 8 );
data = calloc( 1, bytesPerRow * height );
context = CGBitmapContextCreate( data, width, height, 8, bytesPerRow, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedFirst );
if ( subrect )
rect = CGRectOffset( rect, -subrect->x, -subrect->y ) ;
CGContextDrawImage( context, rect, image );
unsigned char* buffer = (unsigned char*) data;