1
我想旋轉攝像頭圖像。代碼如下所示:android:如何提高圖像處理的內存管理
Bitmap result = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getWidth(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.save();
canvas.rotate(90);
canvas.translate(0, -1*bitmap.getHeight());
canvas.drawBitmap(bitmap, new Matrix(), null);
canvas.restore();
String path = String.format(dir+"pic_%d.jpg", System.currentTimeMillis());
stream = new FileOutputStream(path);
bitmap.compress(CompressFormat.JPEG, this.imageQuality, stream);
stream.flush();
stream.close();
問題是:我得到一個OutOfMemoryException(第一行)。有沒有辦法通過一個額外的線程或其他解決方案來完成這項工作?縮小圖像目前不是一種選擇。