Discussion:
wxDC::Blit() doesn't work correctly on wxCocoa
Eric Jensen
2014-07-26 11:43:56 UTC
Permalink
Hi.

Someone posted this on the forum:

"wxDC::Blit() doesn't work correctly on wxCocoa"
http://forums.wxwidgets.org/viewtopic.php?f=23&t=39820

I can't test under OSX, but maybe someone can look into it.

Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-07-27 00:35:31 UTC
Permalink
On Sat, 26 Jul 2014 13:43:56 +0200 Eric Jensen wrote:

EJ> "wxDC::Blit() doesn't work correctly on wxCocoa"
EJ> http://forums.wxwidgets.org/viewtopic.php?f=23&t=39820
EJ>
EJ> I can't test under OSX, but maybe someone can look into it.

I don't really know how am I supposed to test for this (AFAIK wxCaret is
fundamentally broken under OS X anyhow). Stefan, does the patch proposed
there, i.e.:

commit 690e08b257385edb31de57649e223f50df445194
Author: Vadim Zeitlin <***@wxwidgets.org>
Date: Sun Jul 27 02:31:57 2014 +0200

Account for the rectangle origin in wxOSX wxWindow::DoGetAsBitmap().

Offset the image by the rectangle origin.

diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm
index 18f3097..c8cd310 100644
--- a/src/osx/cocoa/utils.mm
+++ b/src/osx/cocoa/utils.mm
@@ -608,7 +608,9 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
{
CGImageRef cgImageRef = (CGImageRef)[rep CGImage];

- CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
+ CGFloat x = subrect ? -subrect->x : 0,
+ y = subrect ? -subrect->y : 0;
+ CGRect r = CGRectMake( x , y , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
// since our context is upside down we dont use CGContextDrawImage
wxMacDrawCGImage( (CGContextRef) bitmap.GetHBITMAP() , &r, cgImageRef ) ;
}

look correct to you? If yes, I could commit it (to 3.0 as well?).

Thanks,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Stefan Csomor
2014-07-27 13:50:05 UTC
Permalink
Hi
Post by Vadim Zeitlin
look correct to you? If yes, I could commit it (to 3.0 as well?).
I¹ll check, I have a native overlay code as well in my sandbox, but it
still has some issues Š

Best,

Stefan
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-07-27 17:42:51 UTC
Permalink
On Sun, 27 Jul 2014 13:50:05 +0000 Stefan Csomor wrote:

SC> >look correct to you? If yes, I could commit it (to 3.0 as well?).
SC>
SC> I¹ll check, I have a native overlay code as well in my sandbox, but it
SC> still has some issues Å 

Fixing (and finally documenting/making official) the overlays would be
extremely useful, of course, but if there is really a mistake in
wxDC::Blit() it would be worth fixing regardless...

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...