java - Android libwebp encoding -
would able provide example of using libwebp ndk library encode image webp ?
i'm trying encode image captured camera rgb_565 using code below:
@override public void onpreviewframe(byte[] data, camera camera) { int w = camera.getparameters().getpreviewsize().width; int h = camera.getparameters().getpreviewsize().height; try { int stride = (w + 1) & ~1; byte[] out = libwebp.webpencodergb(data, w, h, stride, 80f); } catch (exception e) { e.printstacktrace(); } }
i've tried several values stride, ranging w, w+1, w*2, w*3 , w*4 ... latter results in fatal exception.
the above code produces black , white image, duplicates picture several times sideways...
i can't tell if webp supports encoding rgb_565 stream, guess no.
as alternative, can convert rgb_888 such in answers given here: how 1 convert 16-bit rgb565 24-bit rgb888?
and correct way stride width*bytesperpixel
, or in case of rgb_888 width * 3
. when encoding rgba_8888 width * 4
.
Comments
Post a Comment