0

このコードを使用して画像を反転しています。

CGAffineTransform trans = CGAffineTransformScale(imageView.transform, -1, 1);
imageView.transform = trans;  

この反転した画像を保存したい場合はどうすればよいですか?iPhoneライブラリに画像を保存するため
に使用していますが、反転した画像ではなく元の画像を保存しています。UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, nil);

あなたの提案は大歓迎です。
助けてくれてありがとう。

4

2 に答える 2

2

あなたがしているように、あなたはUIImageViewそのでX-Axisはないことをひっくり返していますUIImage。したがって、明らかにコードは元の画像を保存します。

保存するUIImage代わりにあなたを裏返します-UIImageView

 UIImage *flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage scale:1.0 orientation: UIImageOrientationUpMirrored];

今あなたの保存方法を使用してください-

UIImageWriteToSavedPhotosAlbum(flippedImage, nil, nil, nil);

編集:

-(void)tapFlipXPosition:(id)sender
{
    UIImage* sourceImage = yourSourceImage;
    UIImage* flippedImage;

    if(sourceImage.imageOrientation == UIImageOrientationUpMirrored)
    {
       flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage scale:1.0 orientation: UIImageOrientationUp];
    }
    else
    {
        flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage scale:1.0 orientation: UIImageOrientationUpMirrored];
    }

    UIImageWriteToSavedPhotosAlbum(flippedImage, nil, nil, nil);
}
于 2012-09-18T10:04:34.760 に答える
-1

このコードを使用してください。ここでは、最初に反転した画像のスクリーンショットを撮り、それを別のimageviewViewに保存してから、この特定の「新しい画像」をPhotoLibraryに保存します。

 UIGraphicsBeginImageContext(BaseView.frame.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *attachimage = [[UIImage alloc]initWithData:Data];
    UIImage *viImage=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    attachimage = viImage;
    UIImageWriteToSavedPhotosAlbum(viImage, nil, nil, nil);
于 2012-09-18T10:03:58.257 に答える