Real Software Forums
http://forums.realsoftware.com/

Cocoa: AntiAliasing broken for masked pictures
http://forums.realsoftware.com/viewtopic.php?f=7&t=47968
Page 1 of 1

Author:  tomis [ Fri May 24, 2013 11:22 pm ]
Post subject:  Cocoa: AntiAliasing broken for masked pictures

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

Author:  rowlands [ Sat May 25, 2013 12:04 am ]
Post subject:  Re: Cocoa: AntiAliasing broken for masked pictures

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 )

Author:  tomis [ Sat May 25, 2013 12:32 am ]
Post subject:  Re: Cocoa: AntiAliasing broken for masked pictures

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/