Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vector Drawables vs Bitmap in terms of RAM (Android)

In terms of RAM utilized by a drawable when it is rendered on on the screen, does it make any difference if the drawable is a vector or a bitmap?

I understand that vectors take less media storage space, but I'm asking about the resident RAM needed in order to render it, since in theory, it is still being drawn onto a canvas with the same amount of pixels in the end.

Thanks!

like image 938
Nerdy Bunz Avatar asked Jun 13 '16 06:06

Nerdy Bunz


People also ask

Is vector graphics better than bitmap?

Bitmap images can be resized, but you may sacrifice pixels in the process. In contrast, vector images can resize themselves without sacrificing image quality, making them more scalable in design.

Is vector bigger than bitmap?

In general, a bitmap graphic is much larger than a similar vector graphic. Bitmap graphics are affected by resolution. If you enlarge a bitmap graphic, it will look jagged. When shrunk, its features become indistinct and fuzzy.

What is the difference between bitmap and drawable in android?

A Bitmap is a representation of a bitmap image (something like java. awt. Image). A Drawable is an abstraction of "something that can be drawn".

What is the difference between how bitmap and vector images are stored?

The main difference between bitmap and vector is that the bitmap graphics use pixels to represent images while the vector graphics use basic geometric shapes to represent the images. Graphics is a powerful media to communicate ideas and concepts.


1 Answers

From the document I read sometime ago (same question with you). The different between these 2 options is the size of APK file after all when you release. SVG will help you save size of apk.

The initial loading of a vector graphic can cost more CPU cycles than the corresponding raster image. Afterward, memory use and performance are similar between the two. We recommend that you limit a vector image to a maximum of 200 x 200 dp; otherwise, it can take too long to draw. Being drawn on view will have those 2 options having same RAM (memory) consumed.

My reference source: https://developer.android.com/studio/write/vector-asset-studio.html#about

like image 163
toantran Avatar answered Oct 31 '22 10:10

toantran