/*计算图像旋转参数*/
void computeParameter()
{
cosAngle = cosf(fAngle); //fAngle的cos值
sinAngle = sinf(fAngle); //fAngle的sin值
f1 = 0.5*(numPixels-1)*(1-cosAngle) - 0.5*(numLines-1)*sinAngle;
f2 = 0.5*(numPixels-1)*sinAngle - 0.5*(numLines-1)*(1-cosAngle);
}
/*进行图像旋转处理*/
void rotate()
{
int i,j,in
tinc;
int intCapYInc;
int intCapX,intCapY;/*旋转前的坐标为(intCapX,intCapY)*/
/*进行图像旋转,重新赋值*/
//方框内奇数行
for(i=intALines;i<intDLines;i++)
{
for(j=intAPixels;j<intDPixels;j++)
{
intInc = i*2; /*看不懂??*/
intCapX = (int)(j*cosAngle + intInc*sinAngle + f1 + 0.5);
intCapYInc = (int)(intInc*cosAngle - j*sinAngle + f1 + 0.5);
if((intCapYInc%2)==0)
{
intCapY = intCapYInc/2;
}
else
{
intCapY = (intCapYInc-1)/2+numLines/2;
}
//判断是否在原图范围内
if((intCapX>=0) && (intCapX<numPixels) && (intCapY>=0) && (intCapY<numLines))
{
//传送亮度信号
*(Uint8 *)(tempYbuffer + i*numPixels + j) = *(Uint8 *)(capYbuffer + intCapY*numPixels + intCapX);
}
else
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF;
}
}
}
//方框内偶数行
for(i=numLines/2+intALines;i<numLines/2+intDLines;i++)
{
for(j=intAPixels;j<intDPixels;j++)
{
intInc = (i-numLines/2)*2 + 1;
intCapX = (int)(j*cosAngle + intInc*sinAngle + f1 + 0.5);
intCapYInc = (int)(intInc*cosAngle - j*sinAngle + f1 + 0.5);
if((intCapYInc%2)==0)
{
intCapY = intCapYInc/2;
}
else
{
intCapY = (intCapYInc-1)/2+numLines/2;
}
//判断是否在原图范围内
if((intCapX>=0) && (intCapX<numPixels) && (intCapY>=0) && (intCapY<numLines))
{
//传送亮度信号
*(Uint8 *)(tempYbuffer + i*numPixels + j) = *(Uint8 *)(capYbuffer + intCapY*numPixels + intCapX);
}
else
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF;
}
}
}
看不懂 intInc 的赋值是什么意思??
一周热门 更多>