The font-awesome icons are vector based, and from my understanding vector iamges are bad in apps since they are very big (in bytes), is this true
for fontawesome icons? In theory, could I use these icons in my game, not only for menu buttons and such, but also for actual game graphics?
I'm planning on doing a very simple game, and I'd hate to get stuck on the design part, not only the drawing of them, but I've had trouble with scaling of
images (according to screen size) in the past, vector images would solve this.
I realize icons are not optimal for game graphics, but would it be usable?
Vector based images are usually smaller than bitmap based images, because they just contain an abstract description of the image content, that can be scaled to virtually any size.
Your graphics card does not understand these kind of image formats though. You would have to convert them to a bitmap based format first, which means you have to set a specific size for the resulting image.
LibGDX offers the FreeType extension, to convert TrueType font files (.ttf) at runtime to a BitmapFont with a specific size, which can then be rendered.
That way you will be able to generate icons on the fly for the correct display size, without having to ship many different versions of them, for different resolutions.
Related
For using images in my android application, I will use this technique :
I put all of my images into "drawable-xhdpi" folder to let the application scale the images down for various resolutions.
I wondering does it make sense ? What is your experiences ?
Thanks for sharing...
UPDATE:
Maybe this method is a nice one, But an another question raises here which is :
Does this technique causes a memory leak for ldpi devices? I don't want to solve the problem by using svg images, Suppose there are bit-mapped images which are not vector based and there is no choice or alternative to replace. using a bitmap is the only choice.however using this method has a cons which will affect the overall layout and in some devices the position of relevant controls will be changed.
While this will work, it's not ideal and not recommended. Please look at the official documentation for Supporting Multiple Screens:
Although the system performs scaling and resizing to make your application work on different screens, you should make the effort to optimize your application for different screen sizes and densities. In doing so, you maximize the user experience for all devices and your users believe that your application was actually designed for their devices—rather than simply stretched to fit the screen on their devices.
And:
Provide different bitmap drawables for different screen densities
By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) and Nine-Patch drawables (.9.png files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen. This scaling can cause artifacts in the bitmaps. To ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
You can use the File / New / Image Asset to automatically generate the scaled assets.
Best way is use SVG files instead of PNG and import them to project in Androis studio: File -> New -> Vector Asset or use icon fonts like https://github.com/mikepenz/Android-Iconics
SVG file is inserted to drawable and converted to PNG files while compile time for back compatibility, but you don't need to maintain a pack of files, but just one vector file.
I use inkscape to create svg drawings and also to convert to png I think the conversion has better quality and supports all svg functions.
With inkscape and a script it is possible to do batch conversion, I have not tried it yet, until now I convert them one by one
We started using vector drawables in our Android application.
I have read about performance issues faced while using raster images in android applications.
Can anyone explain the reason why there is a performance issue ?
Is it okay to use plenty of vector drawables in an application ?
Thanks in advance !!
This isn't really android specific. It's more to do with different image formats. A raster image has a "fixed" size, in the sense that it is always comprised of the same number of pixels, which is one of the major factors in file size (and memory footprint once it's loaded). This also affects your ability to transform the image.
If you want to shrink a raster image, you have to drop pixels, which is necessarily a lossy transform (even though the smaller size makes it difficult or impossible to notice the lost data). To enlarge the image, you have to interpolate pixels: add data that wasn't there in the original image, which means the image will start to pixelate.
With a vector image, on the other hand, the data stored is not in terms of pixels. Instead it stores "paths" that instruct the computer on how to draw the image. These paths are size-independent, which means that its size can be increased or decreased with no loss of data or image quality. Since the size doesn't matter, only the data necessary to hold the paths (and other data) is stored in a vector image file. This means that the file is (generally) much smaller than the equivalent raster image and so takes up less memory when loaded.
Using a vector will mean your app takes less memory and is more easily adaptable to different screen sizes because android can shrink/expand your graphics to fit without losing any quality.
Raster graphics have more complexity to support images that cant be easily convert vectors like shapes. The technique behind raster graphics are uses pixels unlike vectors uses lines as we know path in Android.
So that raster images have more path elements that represents pixels. Android generates images by using these elements. Complex vectors are takes more time when trying to be generated instead loading a given bitmap.
As i know, You shouldnt be able to use raster in Android. It only supports vectors.
Good luck
Emre
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 am currently working on a 2D game for Android. All of the images that I render were created as SVG's and then exported to PNG's which I have placed in my assets directory. These images are also all sprites that I render using a sprite batcher.
My question is around using different versions of the sprites for devices with different densities. I know that when developing a traditional android app you could place separate directories for separate density levels inside of res and then place the correctly sized versions of the images in question in these sub-directories of res.
What is a good approach when dealing with sprite images in the asset directory? Should I just have one copy of the sprites at a really high density / resolution that I use for everything and I just render them on a coordinate system that is independent of screen size or should I resize the image based on screen density before I process it to create all my texture regions? Or is there another solution entirely?
Currently I have one high resolution set of sprites that I use for everything, it just seems wasteful and inefficient for the lower density devices.
the best answer(s) that I got to this question are on gamedev.stackexchange: https://gamedev.stackexchange.com/questions/69970/recommended-way-to-handle-sprite-assets-for-different-screen-densities-android
I am building a simple wallpaper app. I store the wallpaper images(.jpg) as resources in the res folder. I show the user a grid of thumbnails, which I store separately as resources(.jpg) too in res. I want the scrolling through this grid to be smooth and fast. My question is that when I load the gridview using the adapter, In the getView method I convert the resource to a bitmap and then load it in each imageView in the Grid. Would it be faster if I stored the thumbnails as .bmp in the res folder in the first place? Also I've manually created the thumbnails, rather than manipulating the large wallpapers making them at run-time. Each thumbnail is made to scale to width of 120pixels and the grid consists of 120x120 imageviews. So I was wondering how I could load these images quickly and effectively?
Im setting the adapter to the gridview inside Asyntask, but I dont notice an improvement.
Jpeg, which is lossy image compression, usually provides the best quality to size trade-off.
If you're trying to store high quality images then you're almost certainly going to want to use Jpeg.
PNG does has useful features such as allowing you to work with transparency, and, for simple block colour images outputs really small file sizes.
However, the moment you start to create photo quality images, such as wallpapers, as PNG, you're going to see monster file sizes, which on a mobile device is not going to be much fun or much appreciated by the end user.
Also larger files tend to require more system resources (CPU time and RAM), and on a mobile devices these resources are at a premium.
I would suggest that perhaps for thumbnails you might use PNG, and for the full size image use JPEG, but you might do well to see which creates the smallest file, because that is likely to give an good indication of the rendering efficiency i.e. it takes little resources to render a 800b PNG.
Changing your images to the bmp file format could make a little improvement in performance (because JPG is a compressed bitmap image that needs to be decompressed when rendered), but it's usually not worth the major increase in filesize.
I would recommend using the PNG bitmap format because it's light in both rendering and filesize.
As for the rendering in the ListView, you might want to take a look at this question and this code project.