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;
}
*/
}
转载自:
阅读(7711) | 评论(0) | 转发(1) |