WebP for Monkey

Monkey Forums/User Modules/WebP for Monkey

programmer(Posted 2013) [#1]
WebP loader for Monkey. Supported targets: Android, iOS.

Source code: github.com
Precompiled package: monkey-webp.zip

WebP is an image format by Google that employs both lossy and lossless compression. That’s why it can even be used instead of PNG. More details on the WebP website - developers.google.com. You can also find the WebP converter in there.

PNG vs WebP: http://www.andrewmunsell.com/blog/png-vs-webp/
JPG vs WebP: http://www.andrewmunsell.com/blog/jpg-vs-webp/

Installation

iOS
No action is required.

If you have pulled the source code from github.com, it requires to compile WebP.framework. Run the iosbuild.sh script from the webp/native/webp-android-backport/webp-android-backport-library/jni/webp directory. The script will create the WebP.framework directory. Unfortunately, Monkey doesn't support import of the external frameworks, so in the WebP.framework directory rename WebP to WebP.a.

Android
Installation on Android includes two steps:

1. Add a reference to the library in the yourgame.build/android/project.properties file like:
# Project target.
target=android-13
android.library.reference.1=../../webp/native/webp-android-backport/webp-android-backport-library

2. Copy the yourgame.build/android/local.properties file from the your Android project to webp/native/webp-android-backport/webp-android-backport-library. It contains a path to your Android SDK.

Done!

If you have pulled the source code from github.com, you will need to compile the native library using the Android NDK. From the command line, you shall call the ndk-build command in the webp/native/webp-android-backport/webp-android-backport-library directory. Also change target to android-13 at webp/native/webp-android-backport/webp-android-backport-library/project.properties.

Usage

WebP.LoadImage: arguments the same as the arguments of Monkey's LoadImage:

Import webp

Local img:Image = WebP.LoadImage("picture.webp")

...
    
DrawImage(img, 0, 0)


Todo
- add fallback to native API on Android 4.2
- add async image loading
- add more targets


Sammy(Posted 2013) [#2]
What are the advantages over PNG?


Goodlookinguy(Posted 2013) [#3]
Compression size. Also, when it comes to things like real life photos, WebP allows you to have them in a lossless compressed format at a reasonable size. Whereas with png they would have been gigantic.


julesd(Posted 2013) [#4]
Here is a gui, for converting folder with jpg,png and tiff to webp format.
Easy to use.
Just make sure the images you want to convert are in a folder.
Select folder set settings press convert.
webp images will be in same folder.
tested on windows 8 64 bit.

November 8 2013
On hold going to create a trial version.


Soap(Posted 2016) [#5]
Anyone want to volunteer to make this compatible with Mojo2?