设置使用iPhone相机拍摄的图像的类型 [英] set type of an image captured using iPhone camera
本文介绍了设置使用iPhone相机拍摄的图像的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我们使用iPhone相机捕获图片,则默认情况下图像将以JPEG格式保存。
If we capture a picture using iPhone camera, image will be saved in JPEG format by default.
我想以其他格式保存捕获的图像,例如PNG 。
I would like to save the image captured in other formats like PNG. Is it possible?
当我们从应用程序中调用iPhone相机时,是否可以通过代码执行此操作,是否可以设置必须在捕获图片后保存的图像类型?我是说要打开相机并在捕获图片之前设置类型?
Is it possible to do this from code when we invoke iPhone camera from our application, can we set image type it has to be saved after capturing picture? I mean to open Camera and set the type before capturing picture?
推荐答案
这将帮助您将图像保存为png类型
This will help you to save image in png type
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSError *error;
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@.png",@"photoname"]];
[UIImagePNGRepresentation(image) writeToFile:pngPath atomically:NO];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSLog(@"Documents directory: %@", [fileManager contentsOfDirectoryAtPath:documentsDirectory error:&error]);
[self dismissModalViewControllerAnimated:YES];
}
这篇关于设置使用iPhone相机拍摄的图像的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文