0
我遇到问题。我有一个帖子绘制侦听器,我绘制了一个缩放版本的位图。问题源于这样一个事实,即每次发生缩放时我倾向于进行一些缩放(放大放大,缩小缩小)。问题是我不能够循环利用的位图,因为当我试着画后这样做Bitmap.recycle()绘图后调用它
canvas.draw(scaledbitmap,0,0,null);
scaledBitmap.recycle()
我得到的帆布canot抽签回收位例外
有谁知道我怎么会去再造一个位图完成后,以便可以缩放另一个位置,并且不会发生OutOfMemoryException崩溃。
一些代码来告诉你我究竟是如何使用它:
private SpenDrawListener mPosteDrawListener = new SpenDrawListener() {
@Override
public void onDraw(Canvas canvas, float x, float y, float ratio,
float frameStartX, float frameStartY, RectF updateRect) {
if(mLineDrawingBitmap == null)
mLineDrawingBitmap = loadLineDrawingBitmap(mLineDrawingFileName);
Bitmap bm = Bitmap.createScaledBitmap(mLineDrawingBitmap, (int)(mLineDrawingBitmap.getWidth() * ratio), (int)(mLineDrawingBitmap.getHeight() * ratio), true);
/*
float pointX = (mScreenRect.width() - bm.getWidth())/2;
float pointY = mScreenRect.height()/2 - bm.getHeight();
*/
float pointX = frameStartX - (x * ratio);
float pointY = frameStartY - (y * ratio);
//canvas.drawBitmap(bm, 0, 0,null);
canvas.drawBitmap(bm, pointX, pointY, null);
//bm.recycle();
}
};