Scaling bitmaps while drawing - Performance
I read a couple of times now that scaling images while drawing should be avoided, because it costs alot of performance.
Now does that mean that when I have an image view and i set it to a fixed size (anything other than wrap_content) and set scale type to some开发者_开发问答thing like "scaleXY" the image gets scaled while its beeing drawn, or is that ok to so performence-wise?
Thanks!
If you are using software rendering (call Canvas-based rendering prior to 3.0; cases where the hardware renderer isn't used as of 3.0 because you haven't requested it or the device doesn't support it), then scaling a bitmap at draw time will be significantly slower, perhaps in the realm of an order of magnitude. Basically instead of doing essentially a memcpy(), the drawing code needs to retrieve each pixel and place it in to the destination.
If you really need to scale the bitmap, you should consider scaling it prior to drawing and then drawing the pre-scaled version.
精彩评论