gpt4 book ai didi

iphone - UIImagepickercontroller -(void)takePicture 之后立即获取 UIImage

转载 作者:行者123 更新时间:2023-11-29 04:48:39 25 4
gpt4 key购买 nike

我有一个cameraOverlay,它有自己的相机按钮,我使用 takePicture当他们按下相机按钮并使用委托(delegate)方法时的方法

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info{
[CommonClass AddToStack:@"ReviewController:imagePickerController"];
PhotoOverlay *overlay = (PhotoOverlay*)picker.cameraOverlayView;
[overlay setupImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
}

setupImage:方法只是为我在覆盖层上的 UIImageView 设置图像

问题在于 takePicture 之间有 0.3 秒的间隙和 imagepicker 委托(delegate)方法,所以看起来很奇怪。我见过应用程序在使用自定义叠加层时从按下相机立即过渡到最终 View 。

有人遇到过这种情况吗?

最佳答案

获取即时图像的方法是首先对屏幕进行屏幕截图并使用该图像,然后调用 takePicture 并在准备好时将其替换为屏幕截图(屏幕截图是一个较低的屏幕截图)分辨率比实际图像)。

这是我的片段:

-(void)CameraPressedTake
{
extern CGImageRef UIGetScreenImage();
PhotoOverlay *overlay = (PhotoOverlay*)cameraPicker.cameraOverlayView;

CGImageRef cgoriginal = UIGetScreenImage();

float width = 320.0;
float height = 480.0-[overlay myHeight];
//if it's retina...
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) {
width = 2*width;
height = 2*height;
}
CGImageRef cgimg = CGImageCreateWithImageInRect(cgoriginal, CGRectMake(0, 0, width, height));
UIImage *viewImage = [UIImage imageWithCGImage:cgimg];
[overlay setupImage:viewImage];
CGImageRelease(cgoriginal);
CGImageRelease(cgimg);
[cameraPicker takePicture];
}

关于iphone - UIImagepickercontroller -(void)takePicture 之后立即获取 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9224129/

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