Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

when i get UIImage from ALAssetsLibrary,then use "imageToWebP"method, the image color is change #27

Open
lostkid opened this issue Dec 4, 2015 · 2 comments

Comments

@lostkid
Copy link

lostkid commented Dec 4, 2015

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];

@lostkid
Copy link
Author

lostkid commented Dec 4, 2015

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

@nerohem
Copy link

nerohem commented Apr 5, 2016

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants