How to encode WebP animation on Android - android

I can't find any documentation or example code on how to create an animation file in the WebP format on Android. I know how to encode one WebP image from a Bitmap. I also know there exists a webpmux command line utility to combine multiple WebP images into one WebP file containing multiple frames. What I don't know is how to do this from Java code.
I'm perfectly happy with using a high version Android SDK, 4.3+ is fine, which means WebP should be fully supported.

Related

How to mass import/update Android drawables (in PNG format) and overwrite previously converted WEBP drawables?

I have approximately 100+ drawables in my Android project, and recently received updates to 33 of the drawables in PNG format. Normally my workflow is to merge/replace the drawable-... folders to replace drawables that have updates, and retain other drawables that do not need to be updated. This works well when the files are of the same type (all PNG), but recently in an effort to slim down the app, we converted in AS the entire drawable directory to WEBP (lossless). Now when I do merge and replace with updated assets, both PNG and WEBP versions of the same drawables are retained, which causes build failures on every duplicate drawable.
I have tried the "Convert to WEBP" option in AS on the entire merged drawable directory, but this does not attempt to convert the drawables that have existing WEBP files, leaving duplicates all over.
Any suggestions on solutions (aside from manual remove, replace, rename, etc on individual files) would be greatly appreciated!
NOTE: I am asking the design team if they can just give us WEBP files instead, but they are on vacation this week so I was hoping for another way!
I found this type of solution, I hope this goes well for you.
Instead of put new images with webp extension inside the drawable folder, why dont you convert the png images in webp images inside android studio?
This is what you have to do:
select all your images at once
right mouse click
convert to webp
now please attention: uncheck only the "skip images with transparency/alpha channel...",
the rest leave it unchanged
click next for your N images and click finish
now you have replaced all your PNG images with WEBp images
hope this works well for you

Can I use SVGs instead of PNGs to large scale project

We've already built projects like DocuSign in both iOS and Android, we've quite extensive use of documents which is loaded in form of PNGs, where users can quickly move to their selected page (e.g 1 -> 25), so we worked on closely to make it stable and fast but we've requirement to not gets pixelated while zooming (where PNG lack and gets pixelated), so I done R&D on vector base supported in iOS and found that PDF will not fit for our requirement but SVG may fit. But As SVGs aren't natively supported in iOS so
Is it the right decision to use any third party for SVG support in iOS
like https://github.com/SVGKit/SVGKit in large scale projects?
Will memory management will effect I read many links where it
mentioned it's not recommended like
https://www.quora.com/Should-you-use-SVG-files-for-images-in-an-iOS-app
?
Does anybody go through this kind of problem? looking for suggestions and solutions.
NOTE: These images are coming from cloud(our server, google drive, dropbox and One drive)
You can use Vector xml
Right click on rec>drawable folder
select Vector Asset
then select Local file(SVG)
Pick path of svg file
and import this will convert your SVG to the vector xml file, this vector drawable you can use in place of PNG files

Android Studio Vector asset always could not generate a preview

I want to use vector asset in android studio to generate svg xml file,
I convert my png to svg in this web site
but when I use this svg file in vector asset to generate xml file, I get following error message
It display "could not generate a preview"
How can I fix it?
Most of the complaints on this topic are due to people trying to convert SVGs that use features of the SVG standard that are not supported by VectorDrawables. And the SVG to VectorDrawable converter in AndroidStudio only supports those limited features. It doesn't really give much feedback when it encounters things it doesn't support.
Some of the online converters try a bit harder. You might have better success with them.
Otherwise you may have to simplify your SVGs to get them to work.
If you need to display SVGs images that are more complicated than VectorDrawables can handle, then you can always consider using an SVG rendering library for Android. IMHO the best one is AndroidSVG (disclaimer I wrote that one).
There are some cases when your actual .svg file name contains some capital letters. Just rename them in all small letters and try to upload it.
For instance:
If actual .svg image name is mySavedimage.svg {here 'S' is capital which is against norms of android assets}. SO if you rename that file to my_saved_image.svg then this will work as a charm.
hope it helps.
I've never had any luck with those convert sites. You're better off using photo tools to create an SVG. Make sure to follow the SVG guidelines from Android listed here
The error is in the converter. The SVG file might not be proper.
You need to use photo editor tools like Photoshop or Gimp.

Displaying SVG files in Android

I want to create an app that will display position on some floor plan. Navigation is implementing via WiFi in certain way, I've done it and so now I have a problem of displaying floor plan.
It might be in some vector format, after surfing internet for some time I've decided that it must be svg file.
I found some solutions, but it isn't working for me!
Library svg-android
There is opportunity to display .svg files, but only "simple" files. It works fine only for file in tutorial, but not for any other .svg file (for example, some other file, that you'll create with Inkscape).
So, I decided, that I'll parse .svg file, make DOM from it, somehow get objects and attributes and draw it via OpenGL ES.
Apache Batik
At first glance, very good solution, but there is a problem. Android has some "native" apache libraries and when I try to do something with batik, it throws NoClassDefFoundError, because it's searching not in batik libraries, but in "native" libraries.
Of course, we can add source code in our project, take only batik parser for .svg files and edit it in some way, but there is a lot of work, with same success we can write our own parser.
Tiny Line
There is no trial version, but if we'll see description of how it works for svg files and android, we'll see that there is only rasterization of such files and that's all.
Is there any solution better than writing own parser?
Did anyone come across this problem?
I would suggest using #1. Don't write your own parser. It's just going to be a huge headache.
How detailed does your floor plan have to be? android-svg supports SVG fairly well. It just doesn't have great support for filters or light sources. Your SVG isn't going to have those in them (I hope).
If you don't want to do that, look into quad trees. You can render out a huge image and break that down into a quadtree like format then only load the quads you require.
I have authored an SVG libaray for android the website is
http://www.vectoroid.com
the main thing missing is SVG arc support this is currently fixed and will be in a release in the near future.
I am looking for feedback on it, as i have been working on it for about a year. So if you have any please do tell ...
I've using yet another SVG for Android; seems it is relatively new.
GPLv3, CSS2 support, fonts, texts and spans, linear and radial gradients, SVG and SVGZ, initial filtering support, images from assets, from web and inline base64-encoded images. Fastest from all I've tried.
Of course filters support might be better, but except this it works well and even displays 20-megabytes SVG files.
Successfully tested these 2 libraries:
https://github.com/BigBadaboom/androidsvg - Apache License 2.0
https://scand.com/products/svgkit-android/ - needed tweaking to compile with modern SDK (suppress warnings, update gradle file); LGPL / commercial
androidsvg looks better so far.

.tif to .png conversion in Android

As android doesn't support TIIF fromat, so I want to convert a .tif image to .png image in android.
Is there any library or code that can help me out?
whatever i get is not saufficient for this conversion.
i would try http://www.schaik.com/png/tiff2png.html and convert his .c file to .rs so that it works on all android platforms. Or better yet just do the conversion before it gets to the phone.

Categories

Resources