Re: CGLayer resolution on iPhone with Retina display
Re: CGLayer resolution on iPhone with Retina display
- Subject: Re: CGLayer resolution on iPhone with Retina display
- From: Matt Neuburg <email@hidden>
- Date: Sat, 28 Aug 2010 19:18:55 -0700
On Aug 28, 2010, at 1:37 PM, Alex Kac wrote:
> I believe you need to set the scale of the layer to the scale of the device. Here is how we do it where appContentScaleFactor is a global variable we store the scale from at startup:
>
> if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
> appContentScaleFactor = [[UIScreen mainScreen] scale];
>
>
> if ([mainLayer respondsToSelector: @selector(setContentsScale:)])
> mainLayer.contentsScale = appContentScaleFactor;
>
Sure, but a CGLayer has no contentsScale properties (or any other properties). A CGLayer isn't a CALayer... In fact I'm not sure they have anything in common. m.
>
> On Aug 28, 2010, at 3:22 PM, Matt Neuburg wrote:
>
>> In my UIView's drawRect: I derive a CGLayer from the current context, draw
>> into it, and then draw the layer into the context (the view). This still
>> works on iPhone with a Retina display, but the drawing is blocky. You can
>> see the problem perfectly with Apple's own example code (DrawFlag) in the
>> CGLayer Drawing page of the Quartz 2D Programming Guide - the stars in the
>> flag are blocky.
>>
>> I can work around the problem for a double-resolution screen by creating a
>> CGLayer twice the size I need, applying a doubling scale transform, drawing
>> as before into the CGLayer, and then drawing the CGLayer into my view's
>> context scaled back down again.
>>
>> But I feel I shouldn't have to do this. Given that the documentation claims
>> that "a CGLayer has all the characteristics of the graphics context [from
>> which it is derived] - its resolution, colorspace, and graphics state
>> settings," might we call this a bug?
>>
>> m.
>>
>> --
>> matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
>> pantes anthropoi tou eidenai oregontai phusei
>> Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
>> AppleScript: the Definitive Guide, 2nd edition
>> http://www.tidbits.com/matt/default.html#applescriptthings
>> Take Control of Exploring & Customizing Snow Leopard
>> http://tinyurl.com/kufyy8
>> RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
>> TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
>>
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> Alex Kac - President and Founder
> Web Information Solutions, Inc.
>
> "Forgiveness is not an occasional act: it is a permanent attitude."
> -- Dr. Martin Luther King
>
>
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden