• I420转RGB


    http://blog.csdn.net/huiguixian/article/details/17288909

    1. public class YuvToRGB {  
    2.     private static int R = 0;  
    3.     private static int G = 1;  
    4.     private static int B = 2;  
    5.     public static int[] I420ToRGB(byte[] src, int width, int height){  
    6.         int numOfPixel = width * height;  
    7.         int positionOfV = numOfPixel;  
    8.         int positionOfU = numOfPixel/4 + numOfPixel;  
    9.         int[] rgb = new int[numOfPixel*3];  
    10.   
    11.         for(int i=0; i<height; i++){  
    12.             int startY = i*width;  
    13.             int step = (i/2)*(width/2);  
    14.             int startV = positionOfV + step;  
    15.             int startU = positionOfU + step;  
    16.             for(int j = 0; j < width; j++){  
    17.                 int Y = startY + j;  
    18.                 int V = startV + j/2;  
    19.                 int U = startU + j/2;  
    20.                 int index = Y*3;          
    21.                 rgb[index+B] = (int)((src[Y]&0xff) + 1.4075 * ((src[V]&0xff)-128));  
    22.                 rgb[index+G] = (int)((src[Y]&0xff) - 0.3455 * ((src[U]&0xff)-128) - 0.7169*((src[V]&0xff)-128));  
    23.                 rgb[index+R] = (int)((src[Y]&0xff) + 1.779 * ((src[U]&0xff)-128));  
    24.             }  
    25.         }  
    26.           
    27.         return rgb;  
    28.     }  
    29. }  
  • 相关阅读:
    luffy后台登录+注册+课程
    luffy前台登录+注册+课程
    luffy前台准备
    luffy后台准备
    跨域请求
    pip源和虚拟环境的搭建
    Book接口
    drf-Xadmin的使用
    drf-JWT认证
    drf-自动生成接口文档
  • 原文地址:https://www.cnblogs.com/antflow/p/7603508.html
Copyright © 2020-2023  润新知