I use bitmaps in application and work with .bmp or .png formats. I try to comply with standards from developer android page - Supporting Different Densities
But if I use bitmaps on background and also on imageviews and imagebuttons my application is very huge. Let's say about 40 MB. What is the best way to make graphic the smallest size ?
Of course I can use some tools such as PngCrush to decrease size but it helps only little bit.
I was looking on other applications they are full of graphics and it has only for example 12 MB. How does they reach so small size of application ? Because I don't know using openGL, using images is one and only way to use at the moment. What is the difference in data size when using OpenGL in comparision with using images ? Do you think if I have a lot of graphics I must start with OpenGl using ?
Do you have any interesting tips to make the smallest graphic ?
Related
Regarding Android's call to provide multiple versions of a bitmap/image, why can't only the highest resolution image be used?
E.g if the xxhdpi image is available - will that be able to scale down to all lower density versions or will it just mean it will scale bigger than the allocated size (View)?
PS: If I'm using a background image, does scaling matter? E.g. should I still provide multiple versions of 1 image to fit different pixel densities?
Usually image scaling operation is resourceful and the outcome might be worse than using pre-scaled image.
It has already been answered several times, but I will answer it again. Btw I'm not myself a big pro in Android, but I will try to answer in the best way possible.
Automatic scaling is a thing in Android, but using that is a waste of resource, we already know that using a PNG Graphic asset is a waste of CPU/GPU power when we can use XML for basic designs (which uses less resources), so why waste more power for downscaling it (which increases app opening time and makes it laggy), simply creating multiple sized images for different display sizes is the best option.
A simple and convenient option is to use a free software like Adobe XD which supports export into different sizes.
Simple answer: Avoid using PNG(or other image format), but when you don't have other options do create multiple sizes to save resources.
I am working on android app. I see lot of apps say they have hd graphics and i can see some difference in their graphics and mine. I searched on google also but cannot get exact answer as to what actually hd graphics means? Is it some kind of format like .png or is it resolution like 400*800. I mean if i want to make hd image of a simple button how can i do that? Can anyone please explain in deatail keeping android apps in mind. Thanks in advance!
Basically you need to check out the definition of HD. That stands for High Definition and it's main idea is that by making resolution big, on bigger screens the quality of an image or a video won't look bad.
About Buttons, in Android or any other OS most of the times vector graphics are used instead of bitmaps. Vector graphics are just some coordinates which make up graphic, so when you zoom in or display a vector graphic on a big screen it won't lose it's quality. Bitmaps are collections of pixels. Check this out to get a basic understanding of dpi and pixels: http://en.wikipedia.org/wiki/Dots_per_inch
In order to use bitmaps efficiently for buttons and that kind of controls I'd suggest taking a look at this: http://developer.android.com/reference/android/graphics/NinePatch.html
I am developing a live wallpaper and I would like to know how to manage high quality images. I am quite new to android development by the way.
I got 2 questions:
1)The image I use for wallpaper creation is a vector image (2560w x 1600h, 32bit, 10mb exactly), very crispy and with really high resolution. I tried it as a wallpaper and it looks just fantastic (on my tablet). I placed it in the drawable folder. This results in a high dimension .apk file (9 Mb). Is it ok to have files this big enlarge apk dimension or it is a good practice to reduce it as much as possible?
2)When building my wallpaper from the Engine class i'd like to know, after setting the above image as a wallpaper, what is the best practice to scale it fitting XY independant of screen sizes.
PS: What i found to be perfect was the default system android use when you attempt to set an image as wallpaper. What does the system do in that case?
Thanks :)
1.)Since no android device supports resoultion bigger than 1280x760 of what I know, it is not a good practice in having images with bigger size than this as they use a lot of space for nothing.
2.)The DisplayMetrics class has everything you need related to this problem.
I'm quite new to Android game development (and Android development in general).
My first question came when I was creating the background for my first game: which size should I choose?
If I choose 800x480 for example, will it show good on any other resolutions?
And what about my main character? If I make it move 5px/frame (I already know how to make it fps independent, it's just an example), it's not the same to move 5 pixels on a 320px-width screen than on a 800px-width one.
Any advices on this?
Thanks
You should have separate resource files for each of the screen densities you wish to support.
Pick the background size that's supported natively on the device you plan on developing on, and worry about supporting non-native resolutions or adding resources for other resolutions when you're near the end of the project. Don't get bogged down in the weeds.
As #PaulSonier said, don't worry about supporting multiple resolutions until the end.
For now just develop on one device and use 'dp' or 'dip' units whenever possible. This will make it easier at the end to support multiple screen sizes and densities.
As for the background, consider using 9-patches.
You should have a separate set of graphics for each of the resolutions you want to support. If you really want to cover all the current devices and have the crisp and sharp graphics on every one of those and you want to make sure that the aspect ratio doesn't make your game look weird on some devices, you need to prepare your assets in the following resolutions and scales:
854x600 scale 100%
1024x800 scale 120%
1280x1024 scale 160%
1536x1152 scale 192%
1920x1200 scale 240%
2560x1600 scale 320%
Source: http://bigosaur.com/blog/31-android-resolutions-definite-answer
The best solution is to draw all full-screen images at least 2733x2134 pixels and then scale it down. Well, you can scale down images, if you have text, better to use smaller font size and put it over the image. You can do this at run-time or pre-render the text in advance. You can use ImageMagick to automate all that for 6 different sizes so you don't do it manually.
My android app will work for both normal and hdpi device. I don't want to create two sets of images assets for normal and hdpi screen.
So, could I just create image assets for hdpi only, and use them for both normal and hdpi device. Of course, the hdpi images will be auto scaled to fit normal screen devices. Is it OK? How much performance overhead will be caused by auto scaling hdpi images to fit normal screens?
Thanks.
The answer is "it depends".
If you are filling a listview of 10,000 items with images, then there will be a major performance difference.
If you are running a game engine with even fairly simple graphics, then there will be a major performance difference.
If you are making a custom button background scale, don't worry about it.
As far as simple UI's go, providing multiple resources makes it look better but doesn't really affect performance.
The real performance concern is with sprite scaling in games and other high framerate applications.
None. Do the scaling once at startup and keep the scaled image in memory.
You can generate performance statistics using android.os.Debug class
Start tracing by executing Debug.startMethodTracing() and stop it with Debug.stopMethodTracing(). File with the trace will be created on sd card.
Then you can analyze it using TraceView tool.
This should answer you how big is performance overhead of image scaling in your application.
In your position I would generate hdpi set of images and add it to the project.