B4A Library [B4X] WebP images

Cross platform library that loads the new WebP format images.

Android natively supports this format so the regular LoadBitmap methods will also work.

B4i - If you are using a local builder then download the frameworks and add them to the builder: https://storage.googleapis.com/down...eases/webp/libwebp-1.1.0-ios-framework.tar.gz
Implementation is based on @Brandsum code: https://www.b4x.com/android/forum/threads/who-can-help-me-to-create-b4i-library.110896/#post-694480

B4J - Based on: https://github.com/zakgof/webp4j (Apache 2.0 license)
Download the additional jars.
Note that it is a Windows only library.
It will show a warning message in the logs when the first image is loaded. Ignore it.
(SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder")
If you are using the built-in packager then add this line:
B4X:
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, ..\Objects\b4xlibs\Files temp\build\bin\ webp.dll

Usage instructions:

B4X:
Dim WebP1 As WebP
WebP1.Initialize
ImageView1.SetBitmap(WebP1.LoadWebP(File.ReadBytes(File.DirAssets, "1.webp")))
 

Attachments

  • WebP.b4xlib
    295.8 KB · Views: 337
  • B4J_Additional.zip
    352.4 KB · Views: 308

Ferdari

Active Member
Licensed User
Hi @Erel. i tested the lib and the normal ImageView.bitmap=LoadBitmap() in B4A, none of the two plays an animated WebP, is there any instruction that im missing?

I mean if WebP is natively supported by Android it should play an animated webp by default. it does in apps ive seen on the store.
 
Last edited:

Ferdari

Active Member
Licensed User
Top