Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add basic WebP format support. #4

Closed
wants to merge 2 commits into from

Conversation

ImagicTheCat
Copy link
Contributor

As discussed here.

It's a basic encoding (lossless) / decoding implementation. Tested under GNU/Linux.
You're free to use it or not, but at least the work is done if the feature is desired at some point.

- decode/encode
- partial build (platform/unix)
int width, height;
uint8_t *pdata = WebPDecodeRGBA((uint8_t*)data->getData(), data->getSize(), &width, &height);

if(pdata){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per our code style guide, braces go on a new line and there should be a space between the if and the (.

@slime73
Copy link
Member

slime73 commented Feb 12, 2020

Is there a corresponding change to megasource (cmake dependencies) and the love-android repository along with this? Is libwebp trivial to build for macOS and iOS as well?

What sort of use case do you have in mind for webp files that isn't covered by png and jpeg? Adding and then maintaining a dependency like this isn't free for us, so its cost needs to be offset by solid use cases.

@ImagicTheCat
Copy link
Contributor Author

No I didn't take care of the whole cross-platform build process, this is only the implementation and a few changes to test on POSIX systems. I don't know how exactly LÖVE is maintained.

https://developers.google.com/speed/webp/download
Yes, libwebp has probably been designed to be compiled for all those targets. Also, the licence should allow for any kind of distribution in LÖVE.

I understand about the dependency issue, but WebP has potential. I showed some examples on the topic, the basic implementation would give:

  • better compression than PNG and JPEG
  • flexibility with lossy/lossless RGBA (drastically better compression for complex pictures with alpha, animation atlas, etc)

Then you could use the animation feature for interesting stuff, but that would require new APIs.

I don't know if it's worth the effort from your point of view. To me moving forward is important, so if I can get rid of PNG, JPEG and GIF at once in my work with improvements, I will. This pull request is mostly about showing how simple the libwebp API is.

@MikuAuahDark
Copy link
Contributor

Is there a corresponding change to megasource (cmake dependencies) and the love-android repository along with this? Is libwebp trivial to build for macOS and iOS as well?

I'm not sure about iOS and macOS, but I think libwebp integrates with Megasource since it has CMake scripts. It also looks like integrates well with love-android as it provides their own Android.mk file.

@ImagicTheCat
Copy link
Contributor Author

ImagicTheCat commented Apr 26, 2022

With hindsight, altough interesting, supporting WebP is not essential. There is work on new image formats; particularly JPEG XL looks promising.

It seems that the rate of progress is faster than the rate of adoption, we probably need to hit a wall to reach consensus.

@slime73
Copy link
Member

slime73 commented Apr 26, 2022

What I'm really hoping for with WebP is for someone to make a minimal single-file or very small decoding library for it, similar to stb_image or LodePNG, since the reference/official library is so big.

I never looked at the spec or anything though, so I suppose it's possible the format is complicated enough that something as small as LodePNG isn't ever going to happen for WebP.

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

Successfully merging this pull request may close these issues.

None yet

3 participants