在我的應用程序中,我需要在整個屏幕上繪製一個位圖。出於某種原因,當我繪製位圖時,只有部分位圖加載在屏幕的一部分上。換句話說,屏幕上並未顯示全部圖像。下面是一段我的代碼是我畫的位圖:如何在整個屏幕上在畫布上繪製位圖?
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);
}
}
}
createScaledBitmap – mjstam 2015-02-23 16:17:28
這是如何完成的? – 2015-02-24 21:10:48