Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it better to use Bitmap or EncodedImage in BlackBerry?

In BlackBerry, is it better to use the Bitmap class or EncodedImage in terms of memory usage and performance? Are there any specific tips on using these classes?

like image 865
Prabhu R Avatar asked Aug 18 '09 19:08

Prabhu R


1 Answers

My observation is that better:

  • use Bitmap and drawBitmap for elements that require repaint often (ex background image in games)

Maybe it's because Bitmap is a raw format so no performance hit for decoding EncodedImage before drawImage. On the other side, GIF animation works perfectly with EncodedImage.

  • use EncodedImage for animation or for a large amount of resources (ex photos or decore elements)

When you load Bitmap from gif, png, jpg formats they will be opened as an EncodedImage anyway, and if you do this many times, it may beat performance (ex 50 seconds to load 14 png from resources to Bitmaps on bold, avg size 80 kb, tuned up to 2 seconds loading into EncodedImages)

UPDATE stated by Fostah EncodedImage has a getBitmap() function that you can use to convert any EncodedImage to a Bitmap. So you can load in EncodedImage and then use as Bitmap

like image 160
Maksym Gontar Avatar answered Feb 02 '23 03:02

Maksym Gontar