此案例讲的是分通道的图像(就是RGB不同的通道分别保存,分了三块内存),以下代码只是记录用,所以不一定很衔接。
int iRotationType = 1;
if (0 != iRotationType)
{
char* pdataR = new char[Width * Height];
char* pdataG = new char[Width * Height];
char* pdataB = new char[Width * Height];
for (int h = 0; h < Height; h++)
{
for (int w = 0; w < Width; w++)
{
switch (iRotationType)
{
case 1:
{
pdataR[(Width - w - 1) * Height + h] = pSrcdataR[h * Width + w];
pdataG[(Width - w - 1) * Height + h] = pSrcdataG[h * Width + w];
pdataB[(Width - w - 1) * Height + h] = pSrcdataB[h * Width + w];
break;
case 2:
{
pdataR[w * Height + (Height - h - 1)] = pSrcdataR[h * Width + w];
pdataG[w * Height + (Height - h - 1)] = pSrcdataG[h * Width + w];
pdataB[w * Height + (Height - h - 1)] = pSrcdataB[h * Width + w];
break;
}
case 3:
{
pdataR[(Height - h - 1) * Width + (Width - w - 1)] = pSrcdataR[h * Width + w];
pdataG[(Height - h - 1) * Width + (Width - w - 1)] = pSrcdataG[h * Width + w];
pdataB[(Height - h - 1) * Width + (Width - w - 1)] = pSrcdataB[h * Width + w];
break;
}
}
default:
break;
}
}
}
if (1 == iRotationType || 2 == iRotationType)
{
}
delete[] pSrcdataR;
delete[] pdataR;
delete[] pdataG;
delete[] pdataB;
}