+ (UIImage *) imageFromCCImage:(cocos2d::CCImage *) ccImage {
NSUInteger bytesPerPixel = 4;
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
ccImage->getData(),
ccImage->getDataLen() * bytesPerPixel,
NULL);
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
NSUInteger scanWidth = ccImage->getWidth() * bytesPerPixel;
CGImageRef imageRef = CGImageCreate(ccImage->getWidth(),
ccImage->getHeight(),
8,
bytesPerPixel * 8,
scanWidth,
colorSpaceRef,
bitmapInfo,
provider,
NULL,
NO,
renderingIntent);
UIImage *image = [UIImage imageWithCGImage:imageRef];
CGColorSpaceRelease(colorSpaceRef);
CGImageRelease(imageRef);
return image;
}