开发者

Android BitmapFactory.decodeResource multiple times

So开发者_JS百科me background. I currently have a class that is instantiated multiple times and inside the class resides a Bitmap member variable that is set using BitmapFactory.decodeResource on instantiation. At any time I may need to apply a matrix to the bitmap and it's currently done via:

public void applyMatrix(Matrix matrix) {
    mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true);
}

I am making the assumption that every time I instantiate this class it must load the Bitmap into memory (again). Is that in fact the case? I was also considering pre-loading all bitmaps into an array and referencing the index instead, but I would still run into a problem when I need to transform the Bitmap - I would have to create a new Bitmap from the one in memory. Is there a better way to do this?


You should always transform the canvas and not the bitmap. This alleviates all issues I was concerned about.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜