获取UIImage的大小(字节长度)而不是高度和宽度 [英] Get size of a UIImage (bytes length) not height and width

查看:362
本文介绍了获取UIImage的大小(字节长度)而不是高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 UIImage 的长度。不是图像的宽度或高度,而是数据的大小。

I'm trying to get the length of a UIImage. Not the width or height of the image, but the size of the data.

推荐答案

<$ c $的基础数据c> UIImage 可能会有所不同,因此对于相同的图像,可以有不同大小的数据。您可以做的一件事是使用 UIImagePNGRepresentation UIImageJPEGRepresentation 来获得等效的 NSData 为两者构造,然后检查它的大小。

The underlying data of a UIImage can vary, so for the same "image" one can have varying sizes of data. One thing you can do is use UIImagePNGRepresentation or UIImageJPEGRepresentation to get the equivalent NSData constructs for either, then check the size of that.

这篇关于获取UIImage的大小(字节长度)而不是高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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