YUV422 --> RGB 代码

数码相机(YUV422)发送到数码像框(RGB565),调试成功和大家分享。谢谢!
数码相机的代码:
/*
R = Y + 1.4075 *(V-128)
 G = Y – 0.3455 *(U –128) – 0.7169 *(V –128)
 B = Y + 1.779 *(U – 128)
*/
unsigned char GetYUVR(int nY,int nU,int nV)
{
    int nR;    //V=nV-128
    nR = nY + (nV-128)+((nV-128)*103>>8);// v + ((v * 103) >> 8);
    //overflow?
    if( nR > 255 )
    nR = 255;
    if( nR < 0 )
    nR = 0;   
    return nR;
}
unsigned char GetYUVG(int nY,int nU,int nV)
{
    int nG;    //U = nU-128
    nG = nY - (((nU-128)*88>>8)+((nV-128)*183>>8));//((u * 88) >> 8) +((v * 183) >> 8);
    //overflow?
    if( nG > 255 )
    nG = 255;
    if( nG < 0 )
    nG = 0;   
    return nG;   
}
unsigned char GetYUVB(int nY,int nU,int nV)
{
    int nB;
    nB = nY + (nU-128)+((nU-128)*198>>8);//u +( (u*198) >> 8);
    //overflow?
    if( nB > 255 )
    nB = 255;
    if( nB < 0 )
    nB = 0;       
    return nB;
}

    nPixelData = ( nR&0xF8 ) | nG>>5;
    SoPbSPITXByte( nPixelData);//R5G6B5 :high
     
    nPixelData    = ( nG<<3 &0xE0) | nB>>3;
    SoPbSPITXByte( nPixelData );//R5G6B5 :Low
//
想看看彩色图片的黑白效果吗?看看:
    nPixelData = ((* nPIC)&0xF8 )| (* nPIC)>>5 ;//R=G=B=Y:R5G6B5 :high
    SoPbSPITXByte( nPixelData);//(*(unsigned char*)DataAddr);//
   
    nPixelData    = ((* nPIC)<<3 &0xE0) | (* nPIC)>>3;//Y0//R=G=B=Y:R5G6B5 :Low
    SoPbSPITXByte( nPixelData );//R5G6B5 :Low
就贴到这里,谢谢!
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值