Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1553187
  • 博文数量: 239
  • 博客积分: 1760
  • 博客等级: 上尉
  • 技术积分: 1595
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-08 23:53
文章分类

全部博文(239)

文章存档

2016年(1)

2015年(28)

2014年(53)

2013年(42)

2012年(50)

2011年(65)

分类: C/C++

2011-03-06 23:57:29

YUV420旋转90度
void YUVRotate90(BYTE *des,BYTE *src,int width,int height)
{
    int i=0,j=0,n=0;
    int hw=width/2,hh=height/2;
    for(j=width;j>0;j--)
        for(i=0;i        {
            des[n++] = src[width*i+j];
        }

    unsigned char *ptmp = src+width*height;
    for(j=hw;j>0;j--)
        for(i=0;i        {
            des[n++] = ptmp[hw*i+j];
        }

    ptmp = src+width*height*5/4;
    for(j=hw;j>0;j--)
    for(i=0;i    {
        des[n++] = ptmp[hw*i+j];
    }
}


RGB24旋转90度
void RGBRotate90(BYTE *des,BYTE *src,int width,int height)
{

    if ((!des)||(!src))
    {
        return;
    }
      
    int n = 0;
    int linesize = width*3;
    int i,j;
    for (j=width;j>0;j--)
        for (i=0;i        {
            memcpy(&des[n],&src[linesize*i+j*3-3],3);
            n+=3;
        }

    /*

    if((!des)||(!src))
    {
        return;
    }
    int n = 0;
    int linesize = width*3;
    int i;
    int j;
    // 顺时针的旋转的算法
    for(j = 0;j < width ;j++)
        for(i= height;i>0;i--)
        {
            memcpy(&des[n],&src[linesize*(i-1)+j*3-3],3);
            n+=3;
        }
    */
}

转载自:
阅读(7636) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~