Android Question codec->getAndroidPixels() failed when loading WebP

Ferdari

Active Member
Licensed User
Longtime User
Hi Everyone

im having this issue loading a webp on Imageview only on Android 7 to 4.4, i tried using the new webp library but same error:

i have a try catch
B4X:
                    Try
                        'new webp lib
                        Dim WebP1 As WebP
                        WebP1.Initialize
                        Dim bmpbitmap As B4XBitmap=WebP1.LoadWebP(File.ReadBytes(File.DirInternalCache, Filename))
                   
                        ''Dim bmp As B4XBitmap = LoadBitmapResize(File.DirInternalCache,Filename ,ImageView.Width,ImageView.Height,True)
                        ImageView.SetBitmap(bmpbitmap)
                        anim.Start(ImageView)
                        ImageView.SetVisibleAnimated(200,True)
                    Catch
                        LogColor("Error",0xFFFF0000)
                        Log(LastException)
                        Log(LastException.Message)
                    End Try

Error code:
B4X:
(RuntimeException) java.lang.RuntimeException: Error loading bitmap.
codec->getAndroidPixels() failed.

It loads ok on Android 9 and 10, but not on lower Android, i attached some images with error to test
 

Attachments

  • packets.zip
    396.3 KB · Views: 154

Ferdari

Active Member
Licensed User
Longtime User
You can convert the images to animated gifs and use B4XGifView: https://www.b4x.com/android/forum/threads/118550/#content
I already have webps uploaded in my server , i use it in a Lazy loading list, would be a hard work for older devices to convert the images live, also i dont think it are supported(animated webp to gif)

These are animated webp images. They are only supported in Android 9+.
I see, in Android 9+ it don't show the animation, only shows the first frame, that i was expecting on older Android using the webp library, maybe i need to switch to static webp.
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
@Erel Is there a way to extract the first frame from a webp in order to show a preview picture, now animated webps are only shown(first frame) on Android 9+ but on lower android it appears only white.
 
Upvote 0
Top