Find common bytes used by bitmap in Flex

If I load a bitmap using a loader in Flex, I can use loaderInfo.bytesTotal to get the size, total bytes, from the bitmap.

If I create a bitmap at runtime, how can I find out the size, total bytes used by this bitmap.

I ask for advice. Thanks to

+2


source to share


2 answers


var bitmapByteSize: int = bitmap.bitmapData.getPixels (bitmap.bitmapData.rect) .length;



This might do the trick.

+4


source


I think a better solution than the one above would be:

var bitmapByteSize:uint = bitmap.bitmapData.width * bitmap.bitmapData.height * 4;

      



This is because using the getPixels () method creates an extra ByteArray, so it is slow and uses extra memory.

+3


source







All Articles