图片翻转(Raw Image)

时间:2023-03-09 15:15:40
图片翻转(Raw Image)
int TransformImageBuffer(unsigned char* pImageBuffer, int width, int height,unsigned char* targetImageBuffer)
{
//center flip
int nRet = ;
int length = width * height;
for(int i = ; i < length / ; i++)
{
targetImageBuffer[i] = pImageBuffer[length -i -];
targetImageBuffer[length -i -] = pImageBuffer[i];
}
//vertical flip
for(int h = ; h < height; h++)
{
int firstLine = h * width;
for(int w = ; w < width /; w++)
{
int temp = targetImageBuffer[firstLine + w];
targetImageBuffer[firstLine + w] = targetImageBuffer[firstLine + width - w - ];
targetImageBuffer[firstLine + width - w - ] = temp;
}
} //horizon flip
for(int i = ; i < length /; i++)
{
int line = i / width;
int seq = i % width;
int mirrorPoint = (height - line - ) * width - + seq;
targetImageBuffer[i] = pImageBuffer[mirrorPoint];
targetImageBuffer[mirrorPoint] = pImageBuffer[i];
}
return nRet;
}