iPhone - Get a pointer to the data behind CGDataProvider?

非 Y 不嫁゛ 提交于 2019-12-04 16:46:43
jtrim

See this answer: Does CGDataProviderCopyData() actually copy the bytes? Or just the pointer?

Looks like direct access to the buffer behind a CGDataProvider is restricted to private APIs.

Unless you see a performance problem when you use Instruments to measure it, I don't think that copying it twice is a huge problem. You could always store the CFDataRef imgData directly instead of the mybuff.

Edit
I'm talking about this kind of code:
In your class interface add an array:

NSMutableArray *images;

In your init: method: create the array:

images = [[NSMutableArray alloc] init];

and have a dealloc;

-(void)dealloc{
    [images release];
}

and in your code that saves each image:

CGDataRef imageDataRef = CGDataProviderCopyData(CGImageGetDataProvider(myCGImageRef)));
[images addObject: (NSData*)imageDataRef];
CGRelease(imageDataRef);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!