Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Jun 28, 2017 7:06 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Cocoa: AntiAliasing broken for masked pictures
PostPosted: Fri May 24, 2013 11:22 pm 
Offline
User avatar

Joined: Thu Jul 27, 2006 6:31 pm
Posts: 1698
Location: Monterey, CA
RealStudio 2012r2.1, OS X 10.8.3

1. Start a new project
2. Place the below code in the Paint event of the main Window
3. Compile it as Carbon and run. The image will be anti-aliased just fine.
4. Compile it as Cocoa and run. The image will be an unbearable mess.

Has anyone else experienced this or found a fix for this behavior under Cocoa?

EDIT: The current work-around is to pre-composite masked Pictures onto non-masked Pictures. Pictures without modified masks anti-alias just fine.

Thank you.

dim p as Picture
p=new Picture(512,512,32)
p.Graphics.FillRect 0,0,p.Width,p.Height

p.Mask.Graphics.ClearRect 0,0,p.Width,p.Height
p.Mask.Graphics.TextSize=100
p.Mask.Graphics.DrawString "This is an AntiAlias Test",0,p.Mask.Graphics.TextAscent,p.Width
p.Mask.Graphics.DrawRect 0,0,p.Width,p.Height

g.DrawPicture p,0,0,64,64, 0,0,p.Width,p.Height

_________________
ImagePlay Effects Library (40+ image effects in one open source module. No plugins, no dependencies, no restrictions.)
http://imageplay.sourceforge.net/


Top
 Profile  
Reply with quote  
 Post subject: Re: Cocoa: AntiAliasing broken for masked pictures
PostPosted: Sat May 25, 2013 12:04 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
There is another workaround, which is to grab the underlying CGBitmapContextHandle from the Graphics object to set the 'CGContextSetInterpolationQuality' to 3 ( High Quality ).
Declare Sub CGContextSetInterpolationQuality lib "Cocoa" (handle as integer, inValue as integer)
CGContextSetInterpolationQuality( handle, 3 )

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Cocoa: AntiAliasing broken for masked pictures
PostPosted: Sat May 25, 2013 12:32 am 
Offline
User avatar

Joined: Thu Jul 27, 2006 6:31 pm
Posts: 1698
Location: Monterey, CA
rowlands wrote:
There is another workaround […]


Thank you so much! After reading Apple's Documentation I've decided to go with the faster Interpolation they introduced in OS X 10.6

My code is as follows, called in the paint event. (For anyone else reading this, note that g is a graphics context.)

Declare Sub CGContextSetInterpolationQuality lib "Cocoa" (handle as integer, inValue as integer)
CGContextSetInterpolationQuality( g.Handle(Graphics.HandleTypeCGContextRef), 4 )


I can only hope Xojo does this automatically on the backend. It's a serious oversight not to do so.

_________________
ImagePlay Effects Library (40+ image effects in one open source module. No plugins, no dependencies, no restrictions.)
http://imageplay.sourceforge.net/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group