我正在尝试设置一个背景ti位图,然后能够在上面绘制,这样以后我就可以将位图保存到图库中。
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
paint.setStrokeWidth(changeWidth());
if (bitmap == null)
{
bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_4444);
}
//Boolean parameters allowing to change bg in case preference changed
if(prefs_grid)
{
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.grid_view);
}
if(prefs_ruler)
{
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rulers_view);
}
canvas = new Canvas();
try {
canvas.setBitmap(bitmap);
} catch (Exception e) {
e.printStackTrace();
Log.w("setBitmap", "unable to set Bitmap");
}
super.onSizeChanged(w, h, oldw, oldh);
}
这是我更改位图的地方。位图确实发生了变化,但行:
canvas.setBitmap(位图);
不起作用,我不能得到它为什么?
有人能就这个问题咨询我吗。
谢谢