Return correctly scaled bitmaps from wxDC::GetAsBitmap() in wxOSX
Use the scale used by the DC itself, i.e. the scale factor of the window it's associated with. Closes #17302.
This commit is contained in:
committed by
Vadim Zeitlin
parent
38fabf7012
commit
ab60539810
@@ -586,7 +586,9 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
|
||||
if (!m_window)
|
||||
return wxNullBitmap;
|
||||
|
||||
wxBitmap bitmap(subrect ? subrect->GetSize() : m_window->GetSize());
|
||||
const wxSize bitmapSize(subrect ? subrect->GetSize() : m_window->GetSize());
|
||||
wxBitmap bitmap;
|
||||
bitmap.CreateScaled(bitmapSize.x, bitmapSize.y, -1, m_contentScaleFactor);
|
||||
|
||||
NSView* view = (NSView*) m_window->GetHandle();
|
||||
if ( [view isHiddenOrHasHiddenAncestor] == NO )
|
||||
@@ -601,6 +603,12 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
|
||||
CGImageRef cgImageRef = (CGImageRef)[rep CGImage];
|
||||
|
||||
CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
|
||||
|
||||
// The bitmap created by wxBitmap::CreateScaled() above is scaled,
|
||||
// so we need to adjust the coordinates for it.
|
||||
r.size.width /= m_contentScaleFactor;
|
||||
r.size.height /= m_contentScaleFactor;
|
||||
|
||||
// since our context is upside down we dont use CGContextDrawImage
|
||||
wxMacDrawCGImage( (CGContextRef) bitmap.GetHBITMAP() , &r, cgImageRef ) ;
|
||||
}
|
||||
|
Reference in New Issue
Block a user