1
如果我評論這個區塊,那麼GC垃圾郵件就會消失。什麼是垃圾郵件?如果我註釋掉「//清理」部分,那麼垃圾郵件仍然存在。爲什麼logcat被GC信息垃圾郵件?
public void updatePixels()
{
// Fill the bitmap with black.
mBitmap.eraseColor(Color.BLACK);
// Pass bitmap to be rendered by native function.
if(!mNativeHelper.render(mBitmap)) return;
// If FroyVisuals has text to display, then use a canvas and paint brush to display it.
String text = mActivity.mTextDisplay;
if(text != null)
{
// Give the bitmap a canvas so we can draw on it.
mCanvas.setBitmap(mBitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setTextSize(10);
paint.setTypeface(Typeface.create(Typeface.SERIF, Typeface.ITALIC));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setColor(Color.WHITE);
paint.setTextAlign(Paint.Align.CENTER);
float canvasWidth = mCanvas.getWidth();
float textWidth = paint.measureText(text);
float startPositionX = (canvasWidth - textWidth/2)/2;
mCanvas.drawText(text, startPositionX, mTextureWidth-12, paint);
paint = null;
}
// Flip the texture vertically.
Matrix flip = new Matrix();
flip.postScale(1f, -1f);
Bitmap temp = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), flip, true);
// Copy bitmap pixels into buffer.
mPixelBuffer.rewind();
temp.copyPixelsToBuffer(mPixelBuffer);
// Cleanup
temp.recycle();
temp = null;
flip = null;
}
如何在不創建新的位圖對象的情況下翻轉位圖? – Scott 2012-02-29 10:17:46
已在我的答案中添加了一些更多信息以幫助您解決此問題 – Dori 2012-02-29 10:47:55