iOS获得UIImage内存大小
我想获得UIImage对象真正的内存大小。 有3种方法
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
S3:578816
哪一个是对的?
最后一个(s3)是正确的:
- s1是保存到文件时的.png图像的大小
- s2是保存为最佳质量文件时的.jpg图像的大小