使用UIImagePickerController拍照后如何调整图像大小? [英] How to adjust a image size after using UIImagePickerController take a photo?
本文介绍了使用UIImagePickerController拍照后如何调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文档文件夹中保存照片时调整图像大小???
How to resize a image when save photo in document folder ???
这是我在iphone中保存图像的方式。
This is how I save an image in iphone.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imageFile = nil;
NSString *name_png = [NSString stringWithFormat:@"%@.png",photoName];
imageFile = [documentsDirectory stringByAppendingPathComponent:name_png];
[UIImagePNGRepresentation(self.theImageView.image) writeToFile:imageFile atomically:YES];
如何将其从原始大小调整为200 X 200像素?
How to resize it from original size to 200 X 200 pixels?
或者我可以加载图像文件而不是调整大小吗?
Or can I load the image file than resize it?
实际上,我创建了一个包含许多图像的封面流程,图像来自相机。
Actually, I was create a cover flow with many images, and the image was from camera.
我可以找到一个封面流样本,但是当我加载图片时,它充满了iphone屏幕。
I can find a cover flow sample, but when I load image, it full of iphone screen.
不小的封面图片。
推荐答案
UIImage调整大小:通过这个链接。
UIImage resize : Go thru this link.
感谢Paul Lynch。
Thanks to Paul Lynch.
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
这篇关于使用UIImagePickerController拍照后如何调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文