> On May 9, 2020, at 07:41, Gabriel Zachmann <z...@cs.uni-bremen.de> wrote:
> 
> 
>> Also, if you’re already getting a CGImageRef using 
>> CGImageSourceCreateImageAtIndex, why not just set imgLayer.contents to the 
>> CGImageRef? 
> 
> sorry, my previous response regarding this was incomplete. What I am doing is 
> this, in order to get the EXIF orientation right:
> 
>     CIImage * image = [CIImage imageWithCGImage: imageRef];
>     CIImage * orientedimage = [image imageByApplyingOrientation: 
> (CGImagePropertyOrientation) img_orientation];
>     NSCIImageRep * nsimgrep = [NSCIImageRep imageRepWithCIImage: 
> orientedimage];
>     NSImage * nsImage = [[NSImage alloc] initWithSize: nsimgrep.size];
>     [nsImage addRepresentation: nsimgrep];
>     CALayer * imgLayer    = [CALayer layer]; 
>     imgLayer.contents     = nsImage;
> 
> Still, is there a better way?
> 
> Best regards, Gabriel

I’m not at my computer now, but if you load the image using the thumbnail 
option it will give you a properly oriented image. I’ll check the specific 
options when I get home and can look at the code. 

If you’re using CIImage anyway, you can render it back to a CGImageRef with a 
bitmap context, and that can be done in a separate thread as well. Then you 
have a rendered bitmap ready to assign to your CALayer contents property. 

Jim Crate

_______________________________________________

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