本文主要是介绍YUV420旋转执行代码(JAVA版),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
旋转都是顺时针,镜像都是左右镜像;
YUV420_ROTATE_90:
private byte[] YUV420_ROTATE_90(byte[] buffer, int pixel_w, int pixel_h) {byte[] buffer_new = new byte[buffer.length];int k = 0;//Yfor (int i = 0; i < pixel_w; i++) {for (int j = pixel_h - 1; j >= 0; j--) {buffer_new[k] = buffer[j * pixel_w + i];k++;}}//Ufor (int i = 0; i < pixel_w / 2; i++) {for (int j = pixel_h / 2 - 1; j >= 0; j--) {buffer_new[k] = buffer[pixel_w * pixel_h + j * pixel_w / 2 + i];k++;}}//Vfor (int i = 0; i < pixel_w / 2; i++) {for (int j = pixel_h / 2 - 1; j >= 0; j--) {buffer_new[k] = buffer[pixel_w * pixel_h * 5 / 4 + j * pixel_w / 2 + i];k++;}}return buffer_new;}
YUV420_ROTATE_180:
private byte[] YUV420_ROTATE_180(byte[] buffer, int pixel_w, int pixel_h) {byte[] buffer_new = new byte[buffer.length];int k = 0;//Yfor (int j = pixel_h - 1; j >= 0; j--) {for (int i = pixel_w - 1; i >= 0; i--) {buffer_new[k] = buffer[(j + 1) * pixel_w - pixel_w + i];k++;}}//Ufor (int j =
这篇关于YUV420旋转执行代码(JAVA版)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!