Application size on a phone needs to be as small as possible. If I have an image of a sword and then a very similar image of that same sword except that I've changed the color or added flames or changed the picture of the jewel or whatever, how do store things as efficiently as possible?
One possibility is to store the differences graphically. I'd store just the image differences and then combine the two images at runtime. I've already asked a question on the graphic design stackexchange site about how to do that.
Another possibility would be that there is that apk already does this or that there is already a file format or method people use to store similar images in android.
Any suggestions? Are there tools that I could use to take two pngs and generate a difference file or a file format for storing similar images or something?
I'd solve this problem at a higher level. For example, do the color change at run-time (maybe store the image with a very specific color like some ugly shade of green that you know is the color to be fixed at run-time with white or red or blue or whatever actual color you want). Then you could generate several image buffers at load-time.
For compositing the two images, just store the 'jewel' image separately, and draw it over the basic sword. Again, you could create a new image at load-time, or just do the overdraw at run-time.
This will help reduce your application's footprint on flash, but will not reduce the memory footprint when the app is active.
I believe your idea of storing the delta between 2 images to be quite good.
You would then compress the resulting delta file with a simple entropy coder, such as Huffman, and you are pretty likely to achieve a strong compression ratio if similarities with base image are important.
If the similarity are really very strong, you could even try a Range Coder, to achieve less-than-one-bit-per-pixel performance. The difference however might be noticeable only for larger images (i.e higher definition than a 12x12 sprite).
These ideas however will require you or someone to write for you such function's code. This should be quite straightforward.
An very easy approach to do this is to use an ImagePack ( one image containing many ) - so you can easy leverage the PNG or JPG compression algorithms for your purpose. You then split the images before drawing.
Related
I want to develop same UI like this.
In this UI you can see yellow shaded style on right up corner. I want to ask that how can I develop this type of asset in android?
You can do both or even import an SVG which is usually my preferred way. On the link i passed you will see examples of all different methods so I will just give you quick summary here.
If you decide for image-based formats like JPEG,PNG... you will have to import it multiple times for different screen sizes in order not to lose sharpness which will take more storage space
If you decide for vector based graphics like Xml drawables from android or SVG, you end up with more flexibility and programmability of your graphic and less storage space needed. However it can decrease performance of the app if graphic is complicated (not in your case yours is super simple) because it uses computing power to render the vectors instead of just showing file from storage
I am developing an Android app which has hundreds of .jpg files (over 300) each one of around 40kB. I would like to know if there is a way of reducing the size of my app. I looked at a similar question here Reducing Android App Size, but the problem still exists. Is there perhaps a way to compress the images and decompress them in real time when needed, or any other way to make my app more space efficient while not sacrificing speed?
If you have used tinypng for every resource you did your best with this kind of solution. In general, it's better to use vector graphics where the general icon will be <1kb. Also, a vector resource can be animated. If it's quite simply bitmaps, you can generate them in code on demand. Also, you can divide your app by dynamic features and each will be downloaded on demand with their part of the resources.
Is there perhaps a way to compress the images and decompress them in real-time when needed?
There is no standard Android solution out of the box. Probably, you can write something on your own. But this looks like too much effort.
Still, the most practical solution: use vector graphics as max as possible, generate in code what you can generate, compress with tinypng the others. That should be enough or you should have a very good reason for making some extra work.
For more info about vector graphics in android. For standard vector graphic import right in the android studio.
Web-site where you can download icons and insert them into the project.
I am new to Android Studio. While working on front end its sometimes easy to take some parts as png file and place it on the particular position instead of recreating it in xml file. I am confused can we use png all the time ? I am worried about memory space . Like the app contains 50 pages and in each page I use 1-2 assets . I don't want my app to have more than 40mb. What will be the best way to do? Can we store the image as a URL and retrieve it whenever we use. What's the drawback in that way?
So many questions :)
I am confused can we use png all the time ?
Use what's best for your picture. For a photo, a JPEG will probably do better. But if you wish, you can use PNG all the time, yes.
I don't want my app to have more than 40mb.
Check and see. Depends on how big your images are; we can't tell.
What will be the best way to do?
Not enough information to tell you that. In general, there's nothing wrong with using images in assets.
Can we store the image as a URL and retrieve it whenever we use.
Yes.
What's the drawback in that way?
You'll need to get some server space somewhere. Also, there will be a loading latency. Also, your app won't be usable while disconnected from the Internet.
While working on front end its sometimes easy to take some parts as png file and place it on the particular position instead of recreating it in xml file.
That's the part that is confusing to me. Android XML layouts usually contain interactive elements, ones that the user can interact with. Images, on the other hand, tend to be static. What kind of XML is there out there that you think you can replace by an image?
I have 3 sets of 50 images and I have to create the animations for each set of images in Android application. I am able to create a simple application which animate first set of 50 images using the below method,
Added Animation-list xml in drawable folder and called it using frameAnimation.start().
This method didn't work until I kept the following "android:largeHeap="true" in manifest file.
I am not sure whether this is the good way to animate the images (if we have more number of images and each image of more size like 60 KB. Image is JPG format) or not
I browsed and I found that, if we are able to clear the memory and if we are able to maintain less number of images in memory, then our application will work very fine. So I want to know how to clear the memory?
Please let me know do I need to follow different method to animate the images other than I explained above, so that I can clear the memory.
Thanks for your help.
After looking into several posts and doing much research, I finally ended up modifying the images in Imageview programmatically to simulate frame animation. That way I am just maintaining three images in cache at any point of time (previous, current and next one). I hope that this will be useful to others.
It is not a good thing to process a large amount of images in a frame like manner in Android itself as it will trigger the dreaded "Out of Memory" exception.
Clearing the memory itself is not possible. The best fix for this is proper bitmap handling of the app.
I'm not sure but you might want to check on PhoneGap.
Its an HTML5 Engine that we used before to create a game.
By drawing into the canvas itself, we've recreated frame animation with it. It just requires WebDev skills though.
I am creating a simple android app to view a comic book. The pages are large(0.5-1 mb each), high quality .png's and I am loading them into a webview to make use of the built in zoom controls. So far I only have 17 files and the APK size is already about 16 mb. I'm looking to add over 200 files in future updates. I can't really reduce the quality too much because there is small text that must be zoomed-in on to read. Any suggestions? A similar question was posted here: How to reduce App (.apk) Size, but I don't want to lose the quality of the images. I'm not sure if it's appropriate to link to here, but you can have a look at my app by searching for Tracer (by Detour Mobile) on the android market if it helps at all. Thanks in advance.
You could compress them without using lossy compression- e.g. zipping/rarring them, but I don't believe this would gain you much more than a few kilobytes here and there. Otherwise, try using a more compact format than PNG, such as JPEG (you won't lose too much quality.) By the way, all of this was suggested in the referenced post.
If you do decide to scale down the images' size somewhat, be sure to use a method like bicubic sharper- it tends to look better than others when reducing image size.
Another option would be to download the images for the comic that is being read on-the-fly with pre-fetching so reading would not be interrupted as much.
Consider placing your images in Assets folder as opposed to Res. The big difference is, Assets content won't be compiled into R.java class so you will see major storage savings. You'd have to modify your code though as you won't be able to call up the images via the regular r.resID notation, but it's doable
android offers a new way to deal with it.
android app bundle apk size has a maximum size of 150mb
but you can use an asset pack to seperate the apk from the static files
and upload your app
here is a more detailed explanation about asset packs:
https://developer.android.com/guide/playcore/asset-delivery
here is the guide for integrating asset packs with regular android app:
https://developer.android.com/guide/playcore/asset-delivery/integrate-java