#if objc
#import <WebP/decode.h>
-(UIImage *)convertWebPToUIimage: (NSString *) filePath{
NSData *myData = [NSData dataWithContentsOfFile:filePath];
int width = 0;
int height = 0;
WebPGetInfo([myData bytes], [myData length], &width, &height);
uint8_t *data = WebPDecodeRGBA([myData bytes], [myData length], &width, &height);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, data, width*height*4, free_image_data);
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef imageRef = CGImageCreate(width, height, 8, 32, 4*width, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
return [UIImage imageWithCGImage:imageRef];
}
static void free_image_data(void *info, const void *data, size_t size)
{
if(info != NULL)
{WebPFreeDecBuffer(&(((WebPDecoderConfig *)info)->output));}
else
{free((void *)data);}
}
#End If