在图像放大算法中,双线性插值简单而有效,可以让结果图像显得平滑而不是呈现锯齿状。它的原理很简单,把临近四个点的像素值与相应的贡献系数相乘后加起来就可以了。 // bilinear interpolation int x1 = (( int )x) % bp.bmWidth; int y1 = (( int )y) % bp.bmHeight; int x2 = (u1 + 1 ) % bp.bmWidth; int y2 = (v1 + 1 ) % bp.bmHeight; // calculate fractional parts of u and v float fracx = x - floorf(x); float fracy = y - floorf(y); // calculate weight factors float w1 = ( 1.0f - fracx) * ( 1.0f - fracy); float w2 = fracx * ( 1.0f - fracy); float w3 = ( 1.0f - fracx) * fracy; float w4 = fracx * fracy; // get the result return point(x1, y1) * w1 + point(x2, y1) * w2 + point(x1, y2) * w3 + point(x2, y2) * w4; 本文属Span Zhang(张友邦)原创,转载请注明出处。中国原创分形艺术、中国原创分形软件第一站