如何在iOS 4.0+中以字节为单位获取UIImage的大小? [英] How to get Size of UIImage in Bytes in iOS 4.0+?
本文介绍了如何在iOS 4.0+中以字节为单位获取UIImage的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从照片库或相机中挑选图像。
委托方法:
I am trying to pick an image from the photo library or from the camera.
The delegate method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
给我 UIImage
对象。我需要为我的应用程序找到 bytes
中图像的大小。
Gives me the UIImage
object. I need to find the size of the image in bytes
for my application.
我有什么方法可以获得图像的文件类型以及字节大小?
Is there any way I can get the file type of the image and also the size in the bytes?
任何形式的帮助都将受到高度赞赏。
Any kind of help would be highly appreciated.
提前致谢
推荐答案
请尝试以下代码:
NSData *imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((image), 1.0)];
int imageSize = imageData.length;
NSLog(@"SIZE OF IMAGE: %i ", imageSize);
这篇关于如何在iOS 4.0+中以字节为单位获取UIImage的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文