对灰度图像的双线性插值,但是运行后的结果是图像左边有一部分到右边来了,列反了,急求解决方法!谢谢各位了~void ResizeImage8(unsigned char const *InImage, unsigned char *OutImage, unsigned int SWidth,  unsigned int SHeight, unsigned int DWidth, unsigned int DHeight)  
{
unsigned int PtA = 0, PtB = 0, PtC = 0, PtD = 0, PixelValue = 0;   
register unsigned SpixelColNum = 0, SpixelRowNum = 0, DestCol = 0, DestRow = 0;
unsigned int SpixelColAddr = 0, SpixelRowAddr = 0;  
unsigned int ColDelta = 0, RowDelta = 0, scaleV = 0, scaleH = 0;  
unsigned int ContribAandB = 0, ContribCandD = 0;  
unsigned int ContribTem[1944];// max width of image
int i = 0;  

scaleH = (SWidth << 8) / DWidth; //水平方向比例 
scaleV = (SHeight << 8) / DHeight;  //垂直方向比例
// first line
for (DestCol = 0; DestCol < DWidth; DestCol++)
{
SpixelColAddr = DestCol * scaleH;//目标位图上当前像素点离图像原点的水平偏离度
ColDelta = SpixelColAddr & 255;//目标位图上当前像素点离区域原点的水平偏离度
SpixelColNum = (SpixelColAddr - ColDelta) >> 8;//当前像素点A的列号
PtA = InImage[SpixelRowNum * SWidth + SpixelColNum];  

if ((SpixelColNum + 1) < SWidth)  //SpixelRowNum为行号
{
PtB = InImage[SpixelRowNum * SWidth + (SpixelColNum + 1)];

PtC = InImage[(SpixelRowNum + 1) * SWidth + SpixelColNum];

PtD = InImage[(SpixelRowNum + 1) * SWidth + (SpixelColNum + 1)];
}
else  //到图像末尾时,ABCD的值相等
{
PtB = PtC = PtD = PtA;
}
        //X方向插值,B分量
ContribAandB = ColDelta * (PtB - PtA) + (PtA << 8);
ContribCandD = ColDelta * (PtD - PtC) + (PtC << 8);
ContribTem[i++] = ContribCandD;//将C/D的值保存到一个临时数组,因为下一行的A/B等于此时的C/D
        //Y方向插值
PixelValue = ((ContribAandB << 8) + (ContribCandD - ContribAandB) * RowDelta) >> 16;//RowDelta反应了当前像素点离区域原点的垂直距离
        //保存像素值到目标图像
OutImage[DestRow * DWidth + DestCol] = PixelValue;  
}
// other line
for (DestRow = 1; DestRow < DHeight; DestRow++)  
{
i = 0;
SpixelRowAddr = DestRow * scaleV; //目标位图上当前像素点离图像原点的垂直偏离度 
RowDelta = SpixelRowAddr & 255;  //目标位图上当前像素点离区域原点的垂直偏离度
SpixelRowNum = (SpixelRowAddr - RowDelta) >> 8; //当前像素点的行号                

for (DestCol = 0; DestCol < DWidth; DestCol++)  
{  
SpixelColAddr = DestCol * scaleH;  
ColDelta = SpixelColAddr & 255;  
SpixelColNum = (SpixelColAddr - ColDelta) >> 8; //当前像素点的列号  //PtA = InImage[SpixelRowNum * SWidth + SpixelColNum];  

if (((SpixelColNum + 1) < SWidth) && ((SpixelRowNum + 1) < SHeight))//
色信息
{

PtC = InImage[(SpixelRowNum + 1) * SWidth + SpixelColNum];   PtD = InImage[(SpixelRowNum + 1) * SWidth + (SpixelColNum + 1)];  
}
else  
{
PtB = PtC = PtD = PtA;
}  
            //x方向插值
ContribAandB = ContribTem[i];//用到了上一行的插值信息
ContribCandD = ColDelta * (PtD - PtC) + (PtC << 8);
ContribTem[i++] = ContribCandD;//继续保存c.d区间的插值信息
//y方向插值
PixelValue = ((ContribAandB << 8) + (ContribCandD - ContribAandB) * RowDelta) >> 16;  
OutImage[DestRow * DWidth+ DestCol] = PixelValue;  
}
}
}