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.
source
to share