A
A
AndreyIvanoff2011-04-08 15:48:40
iOS
AndreyIvanoff, 2011-04-08 15:48:40

iPhone programming. Fast analogue of CGDataProviderCopyData?

Hello Khabrovites.
Problem:
Where does the UIImage* im image come from. For example, from the iPhone's camera.
We need to take the pixel values ​​from this picture. However, there is a condition - this process must occur quickly .
Now used:

CGImageRef imageRef = im.CGImage;<br/>
NSData *nsData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(imageRef));<br/>
unsigned char const * pixels = (unsigned char*)[nsData bytes];

However, CGDataProviderCopyData apparently copies the data, and this, for a not at all small picture of 2048 by 1536 (what came from the camera, it came), takes as much as 500 mls on the phone. Which is unacceptably long.
The copy operation is not needed, I do not plan to change anything in the picture, and it would not work out.
On this issue I found a link , there the discussion remained unanswered.
The question is how to quickly take raw data from an image?
Another approach is possible - you can get a smaller image from the camera, so why do I get a picture of 2048 by 1536? Perhaps there is a setting that will somehow affect the resolution?
UPD 04/11/11, 16:40: - I made a mistake in the comment below. Not 50 but 7 mls.
The problem was solved. Info: link.
The private function UIGetScreenImage is used. Gives a picture with a resolution of 320 by 480.
The operation (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(imageRef)) for such a picture is performed on my 7 ms device. It's still tolerable.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Limosha, 2011-04-11
@Limosha

UIImagePNGRepresentation
Read the documentation carefully. But I do not guarantee that it does not copy.

A
AndreyIvanoff, 2011-04-11
@AndreyIvanoff

The problem was solved. Info: link .
The private function UIGetScreenImage is used. Gives a picture with a resolution of 320 by 480.
The operation (NSData *) CGDataProviderCopyData (CGImageGetDataProvider (imageRef)) for such a picture is performed on my device 50 mls. It's still tolerable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question