0

私のアプリでは、キャプチャした画像を 2 つの場所で使用しました。

  1. view1: 画像をキャプチャした後、すぐに imageView1 で使用/設定します。
  2. view2: 2 番目のビューの imageView2で imageview1.image を再利用します。

最初の画像 view1 では、逆方向に撮影しても画像は適切に設定されています。

しかし、2番目の画像ではimageviw1.image、逆方向に設定したものを再利用します。

画像をそのまま再利用するには?

4

1 に答える 1

0

使用する

[UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];

例:

typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);  

ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
    ALAssetRepresentation *rep = [myasset defaultRepresentation];
    CGImageRef iref = [rep fullResolutionImage];
    if (iref) {

        UIImage *images  = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];


    }                               
};


ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
{


};    

NSURL *asseturl = [NSURL URLWithString:@"fileURL"];
assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:asseturl 
               resultBlock:resultblock
              failureBlock:failureblock];
于 2012-10-12T11:12:47.107 に答える