iOS PNG Image rotated 90 degrees

后端 未结 6 1740
猫巷女王i
猫巷女王i 2020-11-28 05:22

In my iOS application I\'m writing, I deal with PNGs because I deal with the alpha channel. For some reason, I can load a PNG into my imageView just fine, but

6条回答
  •  旧巷少年郎
    2020-11-28 05:44

    If you're having trouble due to the existing image imageOrientation property, you can construct an otherwise identical image with different orientation like this:

    CGImageRef imageRef = [sourceImage CGImage];
    
    UIImage *rotatedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:UIImageOrientationUp];
    

    You may need to experiment with just what orientation to set on your replacement images, possibly switching based on the orientation you started with.

    Also keep an eye on your memory usage. Photography apps often run out, and this will double your storage per picture, until you release the source image.

提交回复
热议问题