【问题标题】:How to use images correctly even the camara is captured in reverce direction iphone即使相机是反向拍摄的iphone如何正确使用图像
【发布时间】:2012-10-12 10:45:07
【问题描述】:
在我的应用中,我在两个位置使用了捕获的图像,
-
view1:捕获图像后立即在 imageView1 中使用/设置。
-
view2:在第二个视图中的 imageView2 中重新使用 imageview1.image。
在第一个图像视图 1 中,即使我们以 反方向拍摄,图像也已正确设置,
但在第二张图片中,当我们重用 imageviw1.image 时,它设置为相反的方向。
如何按原样重复使用图像?
【问题讨论】:
标签:
iphone
objective-c
ipad
uiimageview
image-capture
【解决方案1】:
使用
[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];