An ImageView has been loaded with a 1514 × 564 PNG image of 67KB.
A LinearLayout, containing several views including such ImageView, needs to be drawn into a canvas. When calling the method ImageView.draw(Canvas), the canvas size in bytes increases from 67KB to 13MB! (because "draw" draws the bitmap, not the compressed PNG)
Is there an easy way to make imageView draw itself as a PNG?
So far, I've thought of extending ImageView and overriding the draw method with something that compresses the bitmap before drawing.
No, because there is no such concept. Moreover, you already have the PNG, so it is unclear why you are calling draw()` in the first place. If you want a PNG, use your PNG.
That would be pointless, as you would then need to re-decompress the image before drawing it.
Canvas
draws aBitmap
, not a PNG, and aBitmap
is the decompressed image.