0
在我的應用程序我有一個int數組裏麪包含了所有我的位圖的顏色致電:bitmap.getPixels(intArr....)
旋轉位圖使用陣列
我想一個辦法來旋轉這個圖像等90度。我知道這可以用矩陣和畫布來完成,但我也聽說這種方式存儲效率很低。像這樣的例子:
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, config);
Canvas canvas = new Canvas(targetBitmap);
Matrix matrix = new Matrix();
matrix.setRotate(mRotation,source.getWidth()/2,source.getHeight()/2);
canvas.drawBitmap(source, matrix, new Paint());
我想知道是否/如何通過int數組的旋轉可以做,通過循環雖然陣列中的所有元素,並應用某種算法,比,如果這是更多的內存效率一個矩陣。
謝謝!
使用基質(或Canvas.rotate),這是一個最好的辦法 – pskink
你爲什麼要添加標記「OutOfMemoryException異常」?這個異常是否被拋出? – user573215
是的,有時在旋轉更大的位圖時! – Sebastian