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