【发布时间】:2015-02-23 12:14:09
【问题描述】:
在我的应用程序中,我需要在整个屏幕上绘制位图。出于某种原因,当我绘制位图时,只有部分位图加载到屏幕的一部分上。换句话说,不是整个画面都显示在屏幕上。这是我绘制位图的一段代码:
byte[]byteArray=getIntent().getByteArrayExtra("image");
Bitmap tmp=BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
operation = Bitmap.createBitmap(tmp.getWidth(), tmp.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(operation);
Paint paint = new Paint();
tmp.setDensity(c.getDensity());
c.drawBitmap(tmp, 0f, 0f, paint);
tmp.recycle();
还有:
private void drawOverlays() {
Canvas c = null;
try {
c = holder.lockCanvas(null);
synchronized (holder) {
if (c != null)
c.drawBitmap(operation, 0, 0, null);
}
} catch (Exception e) {
Log.e("SurfaceView", "Error drawing frame", e);
} finally {
// do this in a finally so that if an exception is thrown
// during the above, we don't leave the Surface in an
// inconsistent state
if (c != null) {
holder.unlockCanvasAndPost(c);
}
}
}
【问题讨论】:
标签: java android canvas bitmap