iPhone - Get a pointer to the data behind CGDataProvider?

Posted by jtrim on Stack Overflow See other posts from Stack Overflow or by jtrim
Published on 2010-04-29T19:24:20Z Indexed on 2010/04/29 19:27 UTC
Read the original article Hit count: 328

Filed under:
|
|
|
|

I'm trying to take a CGImage and copy its data into a buffer for later processing. The code below is what I have so far, but there's one thing I don't like about it - it's copying the image data twice. Once for CGDataProviderCopyData() and once for the :getBytes:length call on imgData. I haven't been able to find a way to copy the image data directly into my buffer and cut out the CGDataProviderCopyData() step, but there has to be a way...any pointers? (...pun ftw)

NSData *imgData = (NSData *)(CGDataProviderCopyData(CGImageGetDataProvider(myCGImageRef)));

CGImageRelease(myCGImageRef);

// i've got a previously-defined pointer to an available buffer called "mybuff"
[imgData getBytes:mybuff length:[imgData length]];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about c