Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

H2G2

macrumors newbie
Original poster
May 26, 2009
12
0
Hi,

I am currently using a UIImageView to display a UIImage in which I stored home-made jpeg images.
Those image are computed at a quite fast rate (> 25/second), but UIImageView does not match the frame rate I expected (Actually, it is closer to 10 fps), whatever compression feature I use, and ever if I choose another image format (tried with PNG).

Then, I decided to try it another way, using the image data as an OpenGLES 2D texture : I already managed to do so with raw image files, and it was really faster than an UIImageView (I did not mesurate, but I can assume I was over 25 FPS) with the same dimensions images.
You could ask thus why I don't keep using raw images instead of JPEG files : it's because my current home-made images are JPEG-born. I can't change this.

Now, I am trying to find a way to convert my initial JPEG image (stored in a NSData object) to raw data (data only, without header), so that I can use them for my OpenGLES texture.

I know there was a way to do it, which was described here . But now, some of these functions are deprecated, and I can't find a way to have it work.
I am thus still wondering if there is a "nice" and especially fast way to convert any JPEG image to a raw representation. I know a few librairies that do such, but none of them were designed to be compiled on the iPhone OS.

If any of you have any idea about this, I'd take great attention about your answer.

Thanks for reading until the end
 
Thanks for you answer kainjow... even if I feel a little embarassed now.... I use a very similar code : since it looked like it was exactly the same, I assumed it was.
Thus I was about to build my code another time to make a screenshot of the "deprecated" functions, but I realized there were actually a few subtle minor changes...

For example :
Code:
colorSpace  = CGColorSpaceCreateWithName(kCGColorSpaceSRGB)
was replaced by

Code:
colorSpace = CGColorSpaceCreateDeviceRGB();

Indeed, I have no more deprecated functions now.
However I would have described the results If my computer had not crashed down just after a successfull building....

Until it is fixed, or until I get a new one, I still have a question... the same question actually. Since all these operations look like they are not the fastest way to go basicely from JPEG to raw, I still think the intuitive way to do it would be a direct JPEG decompression algorithm that would take a JPEG byte array as an input and returns a raw RGB data array.

Then, my question remains... if you know of such an algorithm that I can use on iPhone (or Mac Os at least).
 
h2g2, i think you are basically looking for a way to decode jpeg images into rgb and manipulate them as such (as bitmaps), rather than in their compressed form. you have the UIImage class for that: in essence, the UIImage payload is represented internally as an rgb. so if you're concerned about the speed, you will be practically in a race to do better than the UIImage implementation. however i understand that whatever UIImage offers would not be enough for you if you want to draw on the image.
 
drivefast, I am sorry for answering you that late : didn't see that someone else answered me.
Yes you are right about that : I am trying to compete with UIImage display.

I still haven't got my computer back from fixing, but I think I have a few ideas about how to do it, now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.