开发者

UIImage+Resize.h - wrong affine transformation given for UIImageOrientationUp orientation

开发者 https://www.devze.com 2023-01-17 05:39 出处:网络
For the UIImage resize I used the following class. http://iphone.svn.wordpress.org/trunk/UIImage+Resize.m

For the UIImage resize I used the following class.

http://iphone.svn.wordpress.org/trunk/UIImage+Resize.m

But I am having issues in some iPhone orientation where I keep the phone in lined with a vertical surface. It does the resize properly but the image is not properly affine transformed. The image orientation is different. I logged the messages in the "transformForOrientation" method where it called the UIImageOrientationUp where I do not see any manipulation done to that orientation. I believe that's the reason for me to get an invalid transformation. So I need a help to fix this issue. Is there any "CGAffineTransformTranslate" or "CGAffineTransformRotate" to add in order to get the correct output.

Please advise me.开发者_JAVA技巧

Thank you.


The - (UIImage *)croppedImage:(CGRect)bounds; method in UIImage+Resize method doesn't take into account the orientation of the image.

Within that method, replace this line:

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];

with this:

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:self.imageOrientation];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号