UIImage memory card

I have one UIImage, and I would like to put its data in a file, and then use the mapped file to save some memory. The data appears to UIImagebe private and cannot be accessed. Do you have any suggestions for solving it?

Thank!

+5
source share
1 answer

If you want the memory card to display encoded image data, then mmap the file and provide a link to the data by passing CGDataProviderRef to CGImageCreate.

mapped = mmap( NULL , length , ... );
provider = CGDataProviderCreateWithData( mapped , mapped , length , munmap_wrapper );
image = CGImageCreate( ... , provider , ... );
uiimage = [UIImage imageWithCGImage:image];
...

Where munmap_wrapper looks something like this:

// conform to CGDataProviderReleaseDataCallback
void munmap_wrapper( void *p , const void *cp , size_t l ) { munmap( p , l ); }

, , , - CGBitmapContext. , , . , . , , .

context = CGBitmapContextCreate( mapped , ... );

__, .

mmap , CGContextDrawImage .

, , . , .

+8

All Articles