在相机视图上覆盖一个框架,然后保存并使用生成的照片(捕获的内容和覆盖框)

我想在我的应用程序中有一个function

– 您拍摄自己或其他有名气的照片,例如“通缉令”,叠加在上面。

– 用户然后将照片和覆盖和照片将被合并成一个

– 在代码中可用的结果图像。

任何想法在哪里/如何从这开始。 任何教程等

干杯

它可能会有一点棘手,处理应用于图像预览的转换,使其看起来与您通过相机交付的图像有点不同,但这里有一个基本的想法:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *img = [info objectForKey:UIImagePickerControllerOriginalImage]; // Here we are throwing away lots of image resolution -- but since our art is built for the 320 x 480 screen // and we are worried about uploading bandwidth, crunching the image down from ~1600 x 2400 to 320 x 480 just makes sense // note that the proportion is a little different, so the picture is slightly stretched in the y-axis, but this is augmented reality, so we like that // note that hardwareScreenSize has to be determined by checking UIDeviceHardware UIGraphicsBeginImageContext(hardwareScreenSize); [img drawInRect:CGRectMake(0, ((hardwareScreenSize.height - hardwareScreenSize.height ) / 2), hardwareScreenSize.width, hardwareScreenSize.height)]; // this scales overlayImage to fit ontop of camera image [(UIImage *)overlayImage drawInRect:CGRectMake(0, 0, hardwareScreenSize.width, hardwareScreenSize.height)]; UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext(); [finalImage retain]; UIGraphicsEndImageContext();