1
我正在拍攝相機中的圖像,並將其旋轉到新的方向,然後將其粘貼到一般粘貼板上。但是,無論我傳入方向,後來由pasteboard paste命令粘貼的內容都將定向爲UIImageOrientationUp。爲什麼UIPasteboard會忽略我使用的圖片方向?
CGImageRef croppedImageRef = CGImageCreateWithImageInRect([self CGImage], CGRectMake(rect.origin.y, [self size].width - rect.origin.x - rect.size.width, rect.size.height, rect.size.width));
UIImage *croppedImage = [UIImage imageWithCGImage:croppedImageRef scale:self.scale orientation:orientation];
CGImageRelease(croppedImageRef);
[[UIPasteboard generalPasteboard] setImage:croppedImage];
我用類似的代碼,以成功地從相機旋轉圖像,並將其插入到相冊:
CGImageRef croppedImageRef = CGImageCreateWithImageInRect([self CGImage], CGRectMake(rect.origin.y, [self size].width - rect.origin.x - rect.size.width, rect.size.height, rect.size.width));
UIImage *croppedImage = [UIImage imageWithCGImage:croppedImageRef scale:self.scale orientation:orientation];
CGImageRelease(croppedImageRef);
[self writeUIImageToCameraRoll:croppedImage withOrientation:orientation];
爲什麼我不能得到的圖像旋轉,我希望爲紙板?是否使用EXIF方向進行粘貼操作?如果是這樣,imageWithCGImage是否將原始EXIF複製到新圖像?