Have a layer that displays an image and has some animations attached.
The animations modify layer.bounds (just the size changes) 
and layer.position .

Everything works fine, EXCEPT when the image's orientation EXIF flag is set.

So, I am also setting the layer.transform to a transformation that brings the 
image into its correct, upright orientation.
This works, EXCEPT that the animations are now off. They still do some 
animations , but the bounds and positions
are not correct any more.

Below are some code excerpts to make this more concrete
and to show how I attempted to deal with the orientation flag of the images.

My main questions are:
Does anyone have experience with this case, i.e., animations of layers that 
show images that have a non-upright EXIF orientation?
Is there a better/different way of handling non-upright EXIF orientation flags 
of images, something other than setting the transformation of the layer 
(layer.transform) ?

All hints and insights will be highly appreciated.

Best regards, Gabriel


Encl:

Here are more details.

Here is a code excerpt:

CALayer * imgLayer = [CALayer layer];
imgLayer.contents    = (__bridge id) imageRef;
imgLayer.anchorPoint  = CGPointMake( 0.0, 0.0 );
CGAffineTransform img_trf = ... compute a CGAffineTransform based on the EXIF 
orientation flag (in [1,8])   (*)
imgLayer.transform = CATransform3DMakeAffineTransform( img_trf );

CABasicAnimation * anim = ... set up the animation(s)

... compute NSRect from_rect, to_rect  that will be used to set up the 
animations of the layer ...
from_rect = CGRectApplyAffineTransform( from_rect, img_trf );
anim.fromValue = [NSValue valueWithRect: from_rect ];
to_rect = CGRectApplyAffineTransform( to_rect, img_trf );
anim.toValue = [NSValue valueWithRect: to_rect ];

NSPoint fromPos = NSMakePoint( ... );
fromPos = CGPointApplyAffineTransform( fromPos, img_trf );
anim.fromValue = [NSValue valueWithPoint: fromPos];
... similarly for anim.toValue ...


So, for instance, if orientation==2, this means that the image is horizontally 
flipped.
So, the transformation img_trf I compute is
  img_trf = CGAffineTransformMake(-1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
i.e., the x-coord is flipped.
The CGRectApplyAffineTransform() call does not change the rectangles, which is 
reasonable.
The x-coord of fromPos and toPos are flipped (sign is inverted), as expected.
BUT the animation does not do what it should , the image is way off the screen.


I have, of course, also tried without any transformations on the bounds 
(from_rect, to_rect)
and without transforming anim.fromValue, anim.toValue.
But then the (oriented) image was completely invisible , maybe way off the 
screen.
So, it seems that the CALayer's transformation machinery does not take care of 
adjusting bounds/position when a layer's transform is set.




Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to