0

We decode an image(JPEG/PNG) into a bitmap on IOS, generally, by CGImage. Now I want to know whether it's the most efficient way to decode an image ??

Or could anyone tell me that is there any API for us to decode an image by ourselves on IOS ??

Coomy
  • 3
  • 3

1 Answers1

1

You could use LodePNG to decode PNG files, but I don't know how much more efficient it would be. Also you won't be able to use it with UIKit without creating a UI or CGImage, so what is the point?

borrrden
  • 33,256
  • 8
  • 74
  • 109
  • 1
    As I know, CGImage saves an image as a bitmap, no matter PNG or JPEG. I want to know that how does IOS decode an PNG image i set into a bitmap(CGImage). Is there any API that I can call to do this? Or, what else of other way to decode an image,,not by CGImage. Do I describe right and strict? – Coomy Jul 12 '12 at 06:08
  • 1
    CGImage doesn't *save* anything, it is a memory buffer. The library I listed will decode PNG files into pixel data. That's all that CGImage does (for JPG as well, and a couple others). Why do you need to do this outside of CGImage? It's most likely not going to save you any time. – borrrden Jul 12 '12 at 06:24
  • Does CGImage decode a PNG into a pixel data and save it into a memory buffer? Is the 'lodePNG' a different way to decode PNG as CGImage?? I want to find some method else to decode images on IOS, and make sure whether CGImage(IOS's SDK) is the most efficient one or not. Thanks for your reply! I'm a beginner about this , Wish you could help me. – Coomy Jul 12 '12 at 06:42
  • 1
    No, LodePNG is a way to decode PNG data into raw pixel data. As I said **you cannot use it as is** so the question becomes why bother? There is a standard way to do it on iOS (CGImage), and that's the one everyone uses. It works just fine. There is no reason for you to go out benchmarking it until you have proven beyond a doubt that your bottleneck lies there. – borrrden Jul 12 '12 at 06:48
  • I try the 'LodePNG' to decode some images on IOS,,it's nearly 4 times slower than UIImage. – Coomy Jul 13 '12 at 01:29