gpt4 book ai didi

IOS、AVCam,如何预览拍摄的图像?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:19:16 38 4
gpt4 key购买 nike

使用 AVCam 示例,我看不出如何访问 AVCamViewController.m 文件中的图像。我想预览捕获的图像,但我看不到如何在方法中访问此图像: - (IBAction)captureStillImage:(id)sender 在行之后: [[ self captureManager] captureStillImage];

我想像这样以编程方式添加预览:

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320/5, 480/5)];
[imageView setImage:[captureManager image]];
[self.view addSubview:imageView];
[imageView release];

我曾尝试在此寻求帮助,但未能成功。这里有人有一些提示吗?

最佳答案

AVcam 将捕获的图像存储在照片库中您需要从照片库中访问最后保存的图像为此您可以使用此方法。您还需要添加 AssetsLiberary.framework 以使用此 als 添加此 #include in .h文件

   #include <AssetsLibrary/AssetsLibrary.h>

@interface PhotoViewController : UIViewController<UIImagePickerControllerDelegate,UIPopoverControllerDelegate>{

ALAssetsLibrary *assetsLibrary;
}
- (void)viewDidLoad
{
assetsLibrary = [[ALAssetsLibrary alloc] init];
[self updateLastPhotoThumbnail];

}
- (void)updateLastPhotoThumbnail
{
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSInteger numberOfAssets = [group numberOfAssets];
if (numberOfAssets > 0) {
NSInteger lastIndex = numberOfAssets-1;
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:lastIndex] options:0 usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
UIImage *thumbnail = [UIImage imageWithCGImage:[result thumbnail]];
if (thumbnail && thumbnail.size.width > 0) {
YouImageView.image = thumbnail;
*stop = YES;
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(@"error: %@", error);
}];
}

关于IOS、AVCam,如何预览拍摄的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11977859/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com