在进行nv21旋转的时候遇到将*2替换成<<1时超出数组范围的错误,在此记录一下
private static byte[] rote(byte[] nv21, int width, int height) {
int ySize = width * height;
byte[] ret = new byte[ySize * 3 >> 1];
for (int y = 0; y < width; ++y) {
for (int x = 0; x < height; ++x) {
ret[y * height + x] = nv21[x * width + width - y];
ret[ySize + (y >> 1) * height + (x >> 1) * 2] = nv21[ySize + (x >> 1) * width + ((width - y - 1) >> 1) * 2];
ret[ySize + (y >> 1) * height + (x >> 1) * 2 + 1] = nv21[ySize + (x >> 1) * width + ((width - y - 1) >> 1) * 2 + 1];
}
}
return ret;
}
本文介绍了一种针对NV21格式图像数据的旋转方法,并详细展示了具体的Java代码实现过程。在实现过程中遇到了使用位左移操作替代乘法运算导致数组越界的问题,并给出了修正方案。
1971

被折叠的 条评论
为什么被折叠?



