YUV420数据格式详解,以图文形式揭示 - 提示:加强阅读理解,配合图片观看更加易懂
最编程
2024-08-15 16:30:18
...
有了上边的理论,我们可以对Android摄像头采集的YUV420sp数据做很多的转换,下面我写一个旋转90度的算法。
代码如下:
[java] view plain copy
- public static void rotateYUV240SP(byte[] src,byte[] des,int width,int height)
- {
- int wh = width * height;
- //旋转Y
- int k = 0;
- for(int i=0;i<width;i++) {
- for(int j=0;j<height;j++)
- {
- des[k] = src[width*j + i];
- k++;
- }
- }
- for(int i=0;i<width;i+=2) {
- for(int j=0;j<height/2;j++)
- {
- des[k] = src[wh+ width*j + i];
- des[k+1]=src[wh + width*j + i+1];
- k+=2;
- }
- }
- }
[java] view plain copy
- public static void rotateYUV240SP(byte[] src,byte[] des,int width,int height)
- {
- int wh = width * height;
- //旋转Y
- int k = 0;
- for(int i=0;i<width;i++) {
- for(int j=0;j<height;j++)
- {
- des[k] = src[width*j + i];
- k++;
- }
- }
- for(int i=0;i<width;i+=2) {
- for(int j=0;j<height/2;j++)
- {
- des[k] = src[wh+ width*j + i];
- des[k+1]=src[wh + width*j + i+1];
- k+=2;
- }
- }
- }