Home > Mobile >  How to put the Bitmap. CreateBitmap replacement for BitmapFactory. DecodeStream
How to put the Bitmap. CreateBitmap replacement for BitmapFactory. DecodeStream

Time:09-15

Source code is: the Bitmap Bitmap=Bitmap. CreateBitmap (mDIBPixels, mDIBWidth, mDIBHeight, Bitmap. Config. ARGB_8888);

MDIBPixels int array, because createBitmap GC is very serious, want to replace BitmapFactory. DecodeStream (), how to do?

CodePudding user response:

Public void drawDIB (Canvas, Canvas) {

Bitmap Bitmap Bitmap=createBitmap (mDIBPixels, mDIBWidth, mDIBHeight, Bitmap. Config. ARGB_8888);
The Rect srcR, dstR;
SrcR=new the Rect (0, 0, 0, 0);
DstR=new the Rect (0, 0, 0, 0);
DstR=getDibShowRect ();

SrcR. Right=mDIBWidth;
SrcR. Left=mDIBWidth - dstR. Width ();
If (srcR. Left & lt; 0)
SrcR. Left=0;
SrcR. Top=0;
SrcR. Bottom=mDIBHeight;

MyApplication app;
App=(MyApplication) (getContext () getApplicationContext ());
Int scanL;
ScanL=app. MRadarDevice. GetScanLength ();
If (scanL & lt; 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);
}

CodePudding user response:

The above function
  • Related