我想在我的应用程序中添加一个功能
- 让您拍摄自己或其他有名望的人的照片,例如在其上叠加“通缉:”。
-然后用户拍摄照片,叠加层和照片将合并为一个
- 可在代码中使用的结果图像。
关于从哪里/如何开始的任何想法。任何教程等
干杯
最佳答案
它可能会有点棘手,处理应用于图像预览的变换,这使得它看起来与您通过相机处理的图像有点不同,但这是基本思想:
- (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();
关于iphone - 在相机 View 上叠加一个框架,然后保存并使用生成的照片(捕获的内容和叠加框架),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4363402/