-1

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 !!

Milind Gaikwad
  • 175
  • 1
  • 7

2 Answers2

0

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

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30
  • Vectors are supported starting from lollipop below that we need to generate normal images using support library and those are in raster format (png). – Milind Gaikwad Nov 30 '16 at 12:01
0

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.

Andrew
  • 518
  • 2
  • 9