Is it better to use Bitmap or EncodedImage in BlackBerry?

前端 未结 1 350
误落风尘
误落风尘 2020-12-30 12:11

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?

相关标签:
1条回答
  • 2020-12-30 13:06

    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

    0 讨论(0)
提交回复
热议问题