簡體   English   中英

iOS獲取UIImage內存大小

[英]iOS get UIImage memory size

我想獲取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圖像的大小

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM