when i get UIImage from ALAssetsLibrary,then use "imageToWebP"method, the image color is change
ALAssetRepresentation *assetRep = [currentAsset defaultRepresentation]; CGImageRef imgRef = [assetRep fullResolutionImage]; UIImage *postImage = [UIImage imageWithCGImage:imgRef scale:assetRep.scale orientation:UIImageOrientationUp]; NSData *imageData = [UIImage imageToWebP:postImg quality:50.f];
then show this imageData in the app, the image Color is wrong. but if I convert native png or jpg to NSData ,it is right. I don't know why.
like this ,it is right. UIImage *image = [UIImage imageNamed:@"xxx.png"]; NSData *imageData = [UIImage imageToWebP:image quality:50.f];
just now change this method "if (alpha < 1) { }" to "if (alpha <= 1) { }", the image color is right.
- (NSData )convertToWebP:(UIImage *)image quality:(CGFloat)quality alpha:(CGFloat)alpha preset:(WebPPreset)preset configBlock:(void (^)(WebPConfig *))configBlock error:(NSError *)error
i have this problem too. But when i change "if (alpha < 1) { }" to "if (alpha <= 1) { }" it also have some problem the webPimage has some white cover on it.