-1

I have a confusion regarding getting number of bytes in UIImage

To get number of bytes we use NSdata byts,

I have have an image of size 128X160 size, and NSData bytes tell it have 400669 bytes

But as per calculation in 3 channel image of 8 bit color i.e 24bit per pixel the number of bytes should be 3X128X160 = 61440 byts

Please help and let me know why NSData tell different in number of bytes?

Thanks

kanwar
  • 19
  • 1

1 Answers1

0

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.

jignesh Vadadoriya
  • 3,244
  • 3
  • 18
  • 29
  • Dear i know UIImagePNGRepresentation can give Size, but i want to know getting size by Manual calculation like i did in question is wrong? – kanwar May 20 '17 at 08:48