Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

define Bitmap bytes count and set limit to bitmap buffer

Tags:

android

bitmap

In my application I have an image viewer and I am getting bitmaps from web server. In order to increase the performance of my app, I have a buffer of bitmaps. The max size of one bitmap can be 0.5mb. I have bufferSize variable where I want to store the buffer bytes count and therefore I need to know each Bitmap size which I am going to add in buffer.And if the bites count exceed some X number I delete the bitmap from front of buffer. And here is my problems:

  1. I don't know how to define bitmap bytes count
  2. I need a suggestion about X number .

Thanks in advance.

like image 802
someUser Avatar asked Nov 05 '22 17:11

someUser


1 Answers

  1. You can get the number of bytes in a Bitmap using the getByteCount() method.
  2. Depends on how much memory your app is using, how many images you are retrieving from the web server, and how often you need to display them. Use some fraction of System.maxMemory(). In any case
like image 156
Sofi Software LLC Avatar answered Nov 14 '22 20:11

Sofi Software LLC