iOS获得UIImage内存大小 [英] iOS get UIImage memory size

查看:2210
本文介绍了iOS获得UIImage内存大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得UIImage Object真正的内存大小。
有3种方法

I want to get UIImage Object real memory size. There are 3 methods

NSUInteger s1 = UIImagePNGRepresentation(thumbImage).length;
NSUInteger s2 = UIImageJPEGRepresentation(thumbImage, 1).length;
NSUInteger s3  = CGImageGetHeight(thumbImage.CGImage) * CGImageGetBytesPerRow(thumbImage.CGImage);
NSLog(@"s1:%u",s1);
NSLog(@"s2:%u",s2);
NSLog(@"s3:%u",s3);

和结果

s1:62734

s2:175939

s2:175939

s3:578816

s3:578816

哪一个是对的?

推荐答案

最后一个(s3)是正确的:

The last one (s3) is correct:


  • s1是保存到文件时.png图像的大小

  • s2是保存到文件时.jpg图像的大小质量最好

这篇关于iOS获得UIImage内存大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆