I am working on a project and dont know which img to use for my icons.
I have already tried searching the web but could not find the exact differnece.
SVGs are vectors, meaning they’re completely customizable. Change the size to big or small, change the colors, or even change the shapes themselves. They will not pixelate as they scale making it great for multiple devices
PNGs come as they are. You can paste or place in any program with any background. You can’t really change the color or shape or the shape and if you try to make them bigger, they will pixelate.
Android does not support SVG. PNG simply for the fact it seems to be a more accepted format than SVG. SVG is scalable, if you have a vector-graphic that is a clear advantage. For pixel-graphics PNG is better but you could create one graphic that looked great on a tiny mobile phone screen or on a 60-inch computer monitor.
Related
I have some background images that have been designed using Photoshop. I did the same image using Illustrator that uses vector graphics, but when deployed the image did not scale very well. Sometimes too big or small. From experimenting, the photoshop images looked much better, even though it used raster images.
I have set the layout background property to this:
android:background="#drawable/camera"
I have just a few questions:
What is better for creating background images, photoshop (raster) or Illustrator (vector)?
As all smart devices are different dpi's and sizes. Is what recommended size should I create the original image when designing it in photoshop or Illustrator?
I noticed that asset studio can create scalable images but can the icon launcher be used for background images, or is it only for launcher icons?
Android Studio 0.5.4
This depends on what your final image should look like or which
tool is better suited for your needs. PS is more suitable to create
pixel graphics and IL is better used for shapes, buttons and so on. In the
end it doesn't matter for android, because internally graphics are
interpreted as bitmaps and therefore are pixel-based. Android
unfortunately doesn't support SVG by default, although there are libs
available.
You should have a look at the supported screens range
http://developer.android.com/guide/practices/screens_support.html#range
You can't really create background images that fit every screen but at least you can approximate them, so only some parts of the image are cut off eventually. Alternatively you can use 9drawables to stretch an image to fit every screen. In that case you will need an image with stretching marks as described here: http://www.vogella.com/tutorials/AndroidDrawables/article.html#drawables_9patch
Asses Studio is best used for Icons. However you could use it for generating the above mentioned 9drawables in the correct sizes: http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html
I'm displaying images from various of sources, and can't control the quality I get, I want to display all images in same size and make them look good no matter how small they are.
Is there a filter, magic effect, whatever I can do to the image to make it look good?
You mean fitting a low-resolution image into a large frame size and still look good and sharp? Android doesn't have this magic. Sorry
You could apply a blur effect on your image, which is what most modern browsers and image viewers do nowadays in order not just to show a big block of pixels - not sure what your scenario is though (native or HTML5 app ? Are the images bundled into the app or are you loading online resources?)...
For starters, here's a nice tutorial on different blur techniques incl. java code samples (Found in this post).
The closest thing Android comes with is to use paint.setFilterBitmap(true) for the paint you use to draw the bitmap.
I'm quite a noob with libGDX for Android (nice OpenGL wrapper that can also work on PC), and I've read some nice examples of how to show images and shapes.
However, when I wanted to check out how to show text, I noticed that the only thing I could see that this library supports is BitmapFont, which uses a bitmap for each character. It's ok for some resolutions and font sizes, but it becomes blurry/pixelated for other cases.
Is there any other way to show text using this cool library? Some kind of way to show vector fonts, and also use more popular fonts files extensions other than ".fnt"?
There is a recent entry on the badlogic blog about generating bitmap fonts on the fly from TrueType font files that should address your problems with packaged font files that are ugly when scaled.
When I was new to Android and libGDX I spent some time looking for a vector font solution to draw scalable text via libGDX. I never found anything (not even generic Java or generic Android). Most font solutions I found are built on bitmaps or were very complex rendering systems (that would be hard to adapt to OpenGL). This seems a bit odd to me too, and I haven't found a coherent explanation.
I don't think there is a proper ways to do so, because libgdx works on openGL too. OpenGL uses textures for displaying images, so that your device is able to draw images hardware accelerated. I don't use libgdx but probably you can write your own function to draw first your vector-based fonts on a texture and then draw your texture on screen. -> But then it's not vectorized anymore.
I am developing an app which has a lot of images to work on due to which the size of my app has become very large. I want to compress or something like that to reduce the size of app. Any idea?
.png-files which are placed in the res/drawable are automatically optimized when compiling your app:
Bitmap files may be automatically optimized with lossless image
compression by the aapt tool during the build process. For example, a
true-color PNG that does not require more than 256 colors may be
converted to an 8-bit PNG with a color palette. This will result in an
image of equal quality but which requires less memory. So be aware
that the image binaries placed in this directory can change during the
build. If you plan on reading an image as a bit stream in order to
convert it to a bitmap, put your images in the res/raw/ folder
instead, where they will not be optimized.
That being said, you have some more options to try. There is a good talk on this topic from Google I/O 2016 called "Image Compression for Android Developers", which outlines the possibilities, explains their up and downsides and gives some general best practices.
If the size of your application is to high to be published on the market, you'll can either
ship your app without the images and load them from the internet to the phones SD-card when the app is first started
Use Androids own APK Extension Files, which is basically the same but you don't have to do everything yourself.
Use pngquant or posterizer to reduce size of PNG images (these tools are lossy, but give significant savings).
You can also optimize them with PNGOUT, which is one of the best lossless optimizers.
I've written Mac GUI for those.
Always use PNG (.png) images.
And compress it online by uploading your images to
https://tinypng.com/
Simple and sober, always work. You are welcome. :)
There is also a better way to use AndEngine, it saves you from making layout for each phone. And there is no need to use different images for different dpi phones.
Do you use 9-patches for backgrounds? Also you can use imagemagick or anything similar to compress a batch or images.
Try and use ".png".
Use 9-patch images for backgrounds.
If you have title bars, headers with vertical gradients, always use 1-pixel width gradient images. This is a super saver.
If you manage to get hold of Photoshop, they have the option to save images for web/mobile devices. Helps in making really small sized images with good quality.
If u r supporting multiple devices, maintain different versions of the images only for those that are really necessary.
I am trying to address a resolution issue when designing HTML for webkit browsers.
So basically the problem is that webkit browsers can have resolution anywhere from 240x320 to 960x640 and I can't have a separate image/icon set for each one but I do want the pages to look the same on all devices (or very close at least).
Scaling the image (working with percentages) works but it's a performance degrade:
http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions
The other option is using vector graphics which is supported in webkit but I am not aware of the performance implications that is going to have on the pages/app.
The other option is to have a few icon sets for some standard well know resolutions and when you get a browser which is outside of these groups you apply some minor scaling on the set which is closest to the users native resolution.
So basically what I am asking is, what would be the best route to achieve this with performance in mind?
Thanks
-Assaf
Vector graphics are always more expensive in terms of runtime performance as complex equations are run to create them. Having said that, I'm not sure if they're redrawn every frame from scratch, or if the result's cached unless it's in a dirty state.
I'd suggest having a few different icon sets for well known resolutions and applying minor scaling if required.
The first answer is not helpful at all. Vector graphics can be just as small as a PNG, and used right can support transparency and various other good features.
The only problem is if your looking for pixel perfect perfection having some of the images scale up might cause problems.
You can also use illustrator to html5 canvas plugin to export directly to html5 canvas.
For our webkit browsers on row icons, we set a property that doesn't allow webkit to scale the icons for desktop browsers. Or for some of the icons we include a small SVG.
They are well supported and work great. Even better would be to use a free font creation tool and paste your vector graphics from illustrator into a font, so that you could use web-font to simply call up ANY size icon, as simple text. We use this technic.