如何将 iPhone 相机拍摄的照片调整为较低的分辨率?我想从 iPhone 相机拍照并在我的应用程序中将其保存为较低的分辨率。(为了节省空间)或者是否可以像发送图片的电子邮件一样显示图片大小的选项?
问问题
943 次
2 回答
3
试试这个:
-(UIImage *)imageWithImage:(UIImage *)imageToCompress scaledToSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[imageToCompress drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
于 2013-02-05T07:23:16.313 回答
1
您可以使用compressionQuality
值压缩图像,
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
//Imagedata = UIImageJPEGRepresentation(<#UIImage *image#>, <#CGFloat compressionQuality#>);
Imagedata = UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],0);
}
您可以使用名称设置大小
NSLog(@"Video size >> %d",(videodta.length/1024)/1024);
[picker addAttachmentData:videodta mimeType:@"video/mp4" fileName:[NSString stringWithFormat:@"My Data (size = %d MB)",(videodta.length/1024)/1024 ]];
于 2013-02-05T08:27:23.313 回答