Determine the number of bitmap bytes and set a limit for the raster buffer

In my application, I have an image viewer and I get bitmap images from a web server. To increase the performance of my application, I have a bitmap buffer. The maximum size of one raster image can be equal to 0.5 MB. I have a bufferSize variable where I want to store the number of bytes in the buffer, and so I need to know every bitmap size that I am going to add to the buffer. And if the number of bites exceeds some number X , I delete the bitmap from the front of the buffer. And here are my problems:

  • I do not know how to determine the number of bitmap bytes
  • I need a sentence about X.

Thanks in advance.

+4
source share
1 answer
  • You can get the number of bytes in a bitmap using the getByteCount () method.
  • Depending on how much memory is used by your application, how many images you retrieve from the web server and how often you need to display them. Use some part of System.maxMemory (). Anyway
+2
source

All Articles