源代碼為:Bitmap bitmap = Bitmap.createBitmap(mDIBPixels, mDIBWidth, mDIBHeight, Bitmap.Config.ARGB_8888);
mDIBPixels為int陣列。由于createBitmap GC太嚴重,想替換成BitmapFactory.decodeStream(),如何實作?
uj5u.com熱心網友回復:
public void drawDIB(Canvas canvas) {Bitmap bitmap = Bitmap.createBitmap(mDIBPixels, mDIBWidth, mDIBHeight, Bitmap.Config.ARGB_8888);
Rect srcR, dstR;
srcR = new Rect(0, 0, 0, 0);
dstR = new Rect(0, 0, 0, 0);
dstR = getDibShowRect();
srcR.right = mDIBWidth;
srcR.left = mDIBWidth - dstR.width();
if (srcR.left < 0)
srcR.left = 0;
srcR.top = 0;
srcR.bottom = mDIBHeight;
MyApplication app;
app = (MyApplication) (getContext().getApplicationContext());
int scanL;
scanL = app.mRadarDevice.getScanLength();
if (scanL < mDIBHeight)
srcR.bottom = scanL;
canvas.drawBitmap(bitmap, srcR, dstR, null);
bitmap.recycle();
boolean mBitMap = bitmap.isRecycled();
if (!mBitMap) {
bitmap.recycle();
} else {
bitmap = null;
}
// DebugUtil.i(TAG,
// "srcR:="+srcR.left+";"+srcR.right+";"+srcR.top+";"+srcR.bottom);
// DebugUtil.i(TAG,"dstR:="+dstR.left+";"+dstR.right+";"+dstR.top+";"+dstR.bottom);
}
uj5u.com熱心網友回復:
上圖是原函式轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/50964.html
標籤:Android
上一篇:相機攝像頭Camera
