Support for WebP

HCAZ

Member
Licensed User
Longtime User
Since Google talked about WebP recently i think for one it would be great to use it more and save space, and two i like the idea of what it can do.
I know that new android supports it, this is for older versions as well.
My questions is will B4A support WebP for use within applications and convert it for us?
Or does anybody know of a library that would allow us to use it / convert it to PNG.

I'm sorry if this is already been asked, but i did look first honest :)

Also for anyone who stumbled across this and does not know what WebP is, here is a page about it [https://developers.google.com/speed/webp/]
 

stevel05

Expert
Licensed User
Longtime User
WEBP is supported natively by Android 4.0+ you can convert an image using the standard BitMap object:

B4X:
Dim BM As Bitmap
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal,"test.webp",False)
BM.Initialize(File.DirAssets,"logo.png")
Try
   BM.WriteToStream(out,100,"WEBP")
Catch
   Log("Android 4.0+ Required to encode WEBP")
End Try

I didn't see any 3rd party converters on Google Play for those with earlier versions of the O/S , online-convert.com does support it, you can see a how-to here.

The other problem I found is that the Image viewer on my HTC Sensation does not recognise the format, Google chrome does. It may take a while for everything to catch up.
 
Last edited:
Upvote 0

HCAZ

Member
Licensed User
Longtime User
I know newer android does, and that chrome does. Good point about using an online convert to handle this for me, but i need to do it on the fly, so i might end up building my own web service to handle it for me.
Its just a shame as for the space i cant use it.
But your code for 4.o+ will help me allot so thank you for that :)

But i shall keep looking i guess, for older android. But thank you for the help :)
 
Upvote 0
Top