seanooi / iOS-WebP

Google's WebP image format decoder and encoder for iOS
http://seanooi.github.io/iOS-WebP/
MIT License
856 stars 138 forks source link

When I set alpah parameter to 1, some colors lose #7

Open gonghao opened 10 years ago

gonghao commented 10 years ago

I met an strange question which is that I compressed an UIImage to WebP, but some colors lose, and I also try to use other quality and WEBP_PRESET but fianlly I find the problem is casued by ALPHA parameter. I tried use other numbers less than 1 all are correct. And I try to edit some source code:

if (alpha <= 1) {
    image = [self webPImage:image withAlpha:alpha];
}

to enforce call webPImage:withAlpha method first and will fix this problem. I don't why, so could you help to fix this issue?

THX

seanooi commented 10 years ago

I might need to run more tests to make sure it works well with most images, but can you provide a screenshot? It seems to be working fine on my end. This is the screenshot I have. http://i.imgur.com/1ItYyX3.png Alpha is 1.0 for the top image, and 0.5 for the bottom image

gonghao commented 10 years ago

@seanooi Hi, I make some tests, when I use iPhone Simulator 7.1 64-bit, it looks very nice. But when I switch to my iPhone 5s, the terrible thing comes.

https://www.dropbox.com/s/l1tmxkgensosq4f/IMG_2631.PNG Here is my screenshot, the top image use Alpha 0.99999, the bottom use 1.f

seanooi commented 10 years ago

I took a closer look at it and noticed the if (alpha <= 1) statement isn't really needed. I will run more tests but it'll most probably be taken out of future releases.

ThePragmaticArt commented 9 years ago

Yeah, same thing is happening to me. Removing the if alpha <= 1 clause corrects the issue when the alpha is one. Otherwise, I consistently get a blue hue on all converted images.