Reputation: 2354
suppose, I've got a png
image A.png
.
Then I add this image to asset catalog in my app, use it at scale 1.
Now, I write the following code:
let im = UIImage(named: "TestByteSet")
let data = UIImagePNGRepresentation(im!)
print("\(data)")
Meanwhile, I open the original file A.png
in a hex-viewer.
The question is: am I supposed to see the same data?
I can see that the beginning is clearly the same, which is not surprising: png
specification tells we have to have png signature at the beginning of the file. However, after some number of bytes data is different.
What am I missing?
Thanks in advance.
Upvotes: 0
Views: 75
Reputation: 17572
PNG file can vary significantly depending on how it is encoded and compressed, so what you see is quite normal
Upvotes: 1