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: Alex Kac <email@hidden>
- Date: Sun, 29 Aug 2010 08:07:38 -0500
Ah, I just read the Layer part and didn’t think of a CGLayer. You are right - a CGLayer has nothing in common. That’s what I get for reading too quickly.
On Aug 28, 2010, at 9:18 PM, Matt Neuburg wrote:
>
> 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
>>
>>
>>
>>
>
Alex Kac - President and Founder
Web Information Solutions, Inc.
"I am not young enough to know everything."
--Oscar Wilde
_______________________________________________
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