Re: Rotated and scaled CALayer
Re: Rotated and scaled CALayer
- Subject: Re: Rotated and scaled CALayer
- From: "Rimas M." <email@hidden>
- Date: Tue, 7 Dec 2010 10:15:33 +0200
Hello Andreas,
Thank you for detailed explanation.
However, I am not able to do what I want. Almost.
I have discovered, that if I use only CA layers transformations (via
setTransform:), I am getting the same rotated pixels when zooming in.
The only way, which does what I want is:
a) use core image filter to rotate layer (simple CIAffineTransform)
b) use second CI filter to tell renderer to use nearest interpolation
instead of linear.
c) use CA transformation to scale layer
Filter mentioned in b) does nothing. It only sets
kCISamplerFilterNearest for kCISamplerFilterMode of the input sampler.
And for c) I am using CATransform3DMakeScale.
Result is OK - when zooming in pixels remains unrotated. But new
problem occurs - when scrolling (even slowly) zoomed in layer, the
"pixels" flickers. And that causes filter of b). If I am not using it,
o its kCISamplerFilterMode setting to the kCISamplerFilterLinear,
flickering is gone. But zoomed pixels becomes rotated.
Rotated pixels:
http://dl.dropbox.com/u/2030721/ForAppleList/Rotated Pixels.png
Expected result:
http://dl.dropbox.com/u/2030721/ForAppleList/Non-rotated_pixels_when_zooming_in.png
Best Regards,
Rimas M.
p.s. I could provide sample application to demonstrate problem.
> - You should add your new layer as a sublayer to the layer of the view-controller's view - or as a sublayer to any other layer than the controller view's layer.
>
> - Usually, you "draw" the contents only once. However, when you set an *image* via the layers's contents property, you don't need to explicitly draw the layer - the layer draws the image for you, when it is required. So, just set the image as the layer's contents.
>
> - You can scale/zoom the layers's contents by setting the layer's transform property accordingly. This uses Core Animation, which executes - if possible - on the GPU, and is therefore the fastest method. Note, this doesn't require the image to be "drawn" again (it requires "rendering").
> You can create a suitable transform which scales AND zooms at once.
>
> - A CALayer's properties are "animatable" (see Core Animation). In fact, changes in properties are animated by default. But you can define any animation, and CA nicely performs them for you.
>
> - Using Core Graphics functions is *usually* not as fast as Core Animation (if a CA alternative exists). But certainly, CG has its use. So, if you want to scale and zoom interactively, use CA.
>
> Regarding transforms, see also:
> CATransform3DMakeRotation, CATransform3DMakeScale, CATransform3DConcat
>
>
> Regards,
>
> Andreas
_______________________________________________
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