Matthew Fisher
Matthew Fisher

Reputation: 183

Speed Comparison decodeResource vs createBitmap

For a current project I need to know which method is faster:

Bitmap.createBitmap(width,height,config)

or

BitmapFactory.decodeResource(getResources(),id)

thanks for your support

Upvotes: 0

Views: 489

Answers (2)

Chris Border
Chris Border

Reputation: 57

I upvoted your answer but it's important to note that these methods are not interchangeable, as some people may assume from the question.
AFAIK, BitmapFactory.decodeResource() is used to instantiate a Bitmap from a resource (e.g. a .png or .xml in the drawable directory),
While Bitmap.createBitmap() is used to instantiate a brand enter code herenew Bitmap (basically from primitives such as float etc), so i don't see how they could be interchangeably used, and hope i saved future readers from scratching their heads a little.

Upvotes: 0

Matthew Fisher
Matthew Fisher

Reputation: 183

I usually ask questions on sites like this because I hope there are some people who may have experienced the same situation or asked themselves the same question as I do. But more and more i recognised that simple questions like the above one,are obviously not wanted here.

The answer for my question is:

Loading Bitmaps is not as fast( and thus efficient) as creating a new one

Thanks for the great help and suggestions

Upvotes: 2

Related Questions