pixel art之 hqx 算法
在去年的时候,偶然看到hqx算法。
一个高质量的插值放大算法。
与双线性插值等插值算法相比,这个算法放大后对人眼保护相对比较好。
没有双线性插值看起来模糊,固然,也抽空把算法简单优化了一下。
官网及代码:
https://web.archive.org/web/20131205091805/http://www.hiend3d.com/hq2x.html
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/hqx/hqx-1.1.tar.gz
维基百科:
https://en.wikipedia.org/wiki/Hqx
不够这个算法写得贼恶心,并不适用于学习。
贴上维基百科上的demo效果对比图。
博主只是简单地把其中的放大两倍的算法,优化了一下,极大地提升算法的速度。
废话不多说,贴上代码:
/* //(c1*3+c2) >> 2; #define Interp1(c1, c2) Interpolate_2(c1, c2, 3, 1, 2); //(c1*2+c2+c3) >> 2; #define Interp2(c1, c2, c3) Interpolate_3(c1, c2, c3, 2, 1, 1, 2); //(c1*7+c2)/8; #define Interp3(c1, c2) Interpolate_2(c1, c2, 7, 1, 3); //(c1*2+(c2+c3)*7)/16; #define Interp4(c1, c2, c3) Interpolate_3(c1, c2, c3, 2, 7, 7, 4); //(c1+c2) >> 1; #define Interp5(c1, c2) Interpolate_2(c1, c2, 1, 1, 1); //(c1*5+c2*2+c3)/8; #define Interp6(c1, c2, c3) Interpolate_3(c1, c2, c3, 5, 2, 1, 3); //(c1*6+c2+c3)/8; #define Interp7(c1, c2, c3) Interpolate_3(c1, c2, c3, 6, 1, 1, 3); //(c1*5+c2*3)/8; #define Interp8(c1, c2) Interpolate_2(c1, c2, 5, 3, 3); //(c1*2+(c2+c3)*3)/8; #define Interp9(c1, c2, c3) Interpolate_3(c1, c2, c3, 2, 3, 3, 3); //(c1*14+c2+c3)/16; #define Interp10(c1, c2, c3) Interpolate_3(c1, c2, c3, 14, 1, 1, 4); */ #define MASK_2 0x0000FF00 #define MASK_13 0x00FF00FF #define MASK_ALPHA 0xFF000000 #define rgb_to_y( c) ((19595 * RED((c)) + 38470 * GREEN((c)) + 7471 * BLUE((c))) >> 16) /* Interpolate functions */ unsigned int Interpolate_2(unsigned int &c1, unsigned int &c2, int w1, int w2, int shift) { if (c1 == c2) { return c1; } return (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24 - shift)) & MASK_ALPHA) + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> shift) & MASK_2) + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> shift) & MASK_13); } unsigned int Interpolate_3(unsigned int &c1, unsigned int &c2, unsigned int &c3, int w1, int w2, int w3, int shift) { return (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24 - shift)) & MASK_ALPHA) + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> shift) & MASK_2) + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> shift) & MASK_13); } void hq2x_32(unsigned int *input, unsigned int *output, int Width, int Height, int Stride) { int Channels = Stride / Width; if (Channels != 4) return; unsigned int pixel[10]; unsigned int gray[10]; int step = 2; unsigned int dstStride = (Width * step)*Channels; int dstWidth = (unsigned int)((Width * step)); for (int y = 0; y < Height; ++y) { int prevline = 0; int nextline = 0; if (y > 0) prevline = -Width; if (y < Height - 1) nextline = Width; unsigned int* srcRowPtr = input + y*Width; unsigned int* dstRowPtr = output + (y<<1)*dstWidth; for (int x = 0; x < Width; ++x) { unsigned int& pixel5 = pixel[5]; unsigned int& pixel2 = pixel[2]; unsigned int& pixel8 = pixel[8]; unsigned int& pixel1 = pixel[1]; unsigned int& pixel4 = pixel[4]; unsigned int& pixel7 = pixel[7]; unsigned int& pixel3 = pixel[3]; unsigned int& pixel6 = pixel[6]; unsigned int& pixel9 = pixel[9]; unsigned int& gray5 = gray[5]; unsigned int& gray2 = gray[2]; unsigned int& gray8 = gray[8]; unsigned int& gray1 = gray[1]; unsigned int& gray4 = gray[4]; unsigned int& gray7 = gray[7]; unsigned int& gray3 = gray[3]; unsigned int& gray6 = gray[6]; unsigned int& gray9 = gray[9]; pixel2 = srcRowPtr[prevline]; pixel5 = srcRowPtr[0]; pixel8 = srcRowPtr[nextline]; if (x <= 0) { pixel1 = pixel2; pixel4 = pixel5; pixel7 = pixel8; } else { pixel1 = srcRowPtr[prevline - 1]; pixel4 = srcRowPtr[-1]; pixel7 = srcRowPtr[nextline - 1]; } if (x >= Width - 1) { pixel3 = pixel2; pixel6 = pixel5; pixel9 = pixel8; } else { pixel3 = srcRowPtr[prevline + 1]; pixel6 = srcRowPtr[1]; pixel9 = srcRowPtr[nextline + 1]; } int pattern = 0; int flag = 1; for (int k = 1; k <= 9; ++k) { gray[k] = (7471 * ((pixel[k] >> 16) & 0xFF) + 38470 * ((pixel[k] >> 8) & 0xFF) + 19595 * (pixel[k] & 0xFF)) >> 16; } for (int i = 1; i <= 9; ++i) { if (i != 5) { if (pixel[i] != pixel5) pattern |= flag; flag *= 2; } } unsigned int * dstCurLine = &dstRowPtr[dstWidth]; unsigned int * dstCurLineNextPixel = &dstRowPtr[dstWidth + 1]; switch (pattern) { case 0: case 1: case 4: case 5: case 32: case 33: case 36: case 37: case 128: case 129: case 132: case 133: case 160: case 161: case 164: case 165: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 2: case 34: case 130: case 162: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 16: case 17: case 48: case 49: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 64: case 65: case 68: case 69: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 8: case 12: case 136: case 140: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 3: case 35: case 131: case 163: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 6: case 38: case 134: case 166: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 20: case 21: case 52: case 53: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 144: case 145: case 176: case 177: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 192: case 193: case 196: case 197: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 96: case 97: case 100: case 101: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 40: case 44: case 168: case 172: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 9: case 13: case 137: case 141: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 18: case 50: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 80: case 81: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 72: case 76: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 10: case 138: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 66: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 24: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 7: case 39: case 135: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 148: case 149: case 180: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 224: case 225: case 228: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 41: case 45: case 169: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 22: case 54: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 208: case 209: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 104: case 108: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 11: case 139: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 19: case 51: if (gray2 == gray6) { dstRowPtr[0] = Interpolate_3(pixel5, pixel2, pixel4, 5, 2, 1, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 146: case 178: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) { dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 5, 2, 1, 3); } else { dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); break; case 84: case 85: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); if (gray6 == gray8) { dstRowPtr[1] = Interpolate_3(pixel5, pixel6, pixel2, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); break; case 112: case 113: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray6 == gray8) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); } break; case 200: case 204: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel8, pixel6, 5, 2, 1, 3); } else { dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } break; case 73: case 77: if (gray8 == gray4) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 5, 2, 1, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); } dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 42: case 170: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel4, pixel8, 5, 2, 1, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 14: case 142: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 5, 2, 1, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 67: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 70: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 28: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 152: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 194: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 98: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 56: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 25: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 26: case 31: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 82: case 214: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 88: case 248: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 74: case 107: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 27: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 86: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 216: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 106: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 30: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 210: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 120: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 75: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 29: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 198: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 184: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 99: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 57: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 71: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 156: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 226: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 60: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 195: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 102: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 153: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 58: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 83: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 92: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 202: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 78: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 154: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 114: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 89: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 90: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 23: case 55: if (gray2 == gray6) { dstRowPtr[0] = Interpolate_3(pixel5, pixel2, pixel4, 5, 2, 1, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = pixel5; } dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 150: case 182: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) { dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 5, 2, 1, 3); } else { dstRowPtr[1] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); break; case 212: case 213: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); if (gray6 == gray8) { dstRowPtr[1] = Interpolate_3(pixel5, pixel6, pixel2, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLineNextPixel [0] = pixel5; } dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); break; case 240: case 241: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray6 == gray8) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = pixel5; } break; case 232: case 236: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel8, pixel6, 5, 2, 1, 3); } else { dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } break; case 105: case 109: if (gray8 == gray4) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 5, 2, 1, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = pixel5; } dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 43: case 171: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel4, pixel8, 5, 2, 1, 3); } else { dstRowPtr[0] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 15: case 143: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 5, 2, 1, 3); } else { dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 124: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 203: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 62: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 211: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 118: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 217: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 110: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 155: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 188: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 185: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 61: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 157: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 103: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 227: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 230: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 199: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 220: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 158: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 234: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 242: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 59: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 121: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 87: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 79: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 122: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 94: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 218: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 91: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 229: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 167: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 173: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 181: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 186: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 115: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 93: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 206: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 201: case 205: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 6, 1, 1, 3); else dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 46: case 174: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 6, 1, 1, 3); else dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 147: case 179: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 6, 1, 1, 3); else dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 116: case 117: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 6, 1, 1, 3); else dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 189: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 231: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 126: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 219: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 125: if (gray8 == gray4) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 5, 2, 1, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = pixel5; } dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 221: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray6 == gray8) { dstRowPtr[1] = Interpolate_3(pixel5, pixel6, pixel2, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLineNextPixel [0] = pixel5; } dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); break; case 207: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 5, 2, 1, 3); } else { dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 238: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel8, pixel6, 5, 2, 1, 3); } else { dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); } break; case 190: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) { dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 5, 2, 1, 3); } else { dstRowPtr[1] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 187: if (gray4 == gray2) { dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 3, 3, 3); dstCurLine[0] = Interpolate_3(pixel5, pixel4, pixel8, 5, 2, 1, 3); } else { dstRowPtr[0] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); } dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 243: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray6 == gray8) { dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 5, 2, 1, 3); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 3, 3, 3); } else { dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = pixel5; } break; case 119: if (gray2 == gray6) { dstRowPtr[0] = Interpolate_3(pixel5, pixel2, pixel4, 5, 2, 1, 3); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 3, 3, 3); } else { dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstRowPtr[1] = pixel5; } dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 233: case 237: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 47: case 175: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); break; case 151: case 183: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 244: case 245: dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 250: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 123: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 95: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 222: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 252: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel2, 2, 1, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 249: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel2, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 235: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_3(pixel5, pixel3, pixel6, 2, 1, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 111: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel6, 2, 1, 1, 2); break; case 63: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel9, pixel8, 2, 1, 1, 2); break; case 159: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel8, 2, 1, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 215: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_3(pixel5, pixel7, pixel4, 2, 1, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 246: dstRowPtr[0] = Interpolate_3(pixel5, pixel1, pixel4, 2, 1, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 254: dstRowPtr[0] = Interpolate_2(pixel5, pixel1, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 253: dstRowPtr[0] = Interpolate_2(pixel5, pixel2, 3, 1, 2); dstRowPtr[1] = Interpolate_2(pixel5, pixel2, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 251: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel3, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 239: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; dstRowPtr[1] = Interpolate_2(pixel5, pixel6, 3, 1, 2); if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel6, 3, 1, 2); break; case 127: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 2, 1, 1, 2); else dstRowPtr[1] = pixel5; if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 2, 1, 1, 2); else dstCurLine[0] = pixel5; dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel9, 3, 1, 2); break; case 191: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); dstCurLineNextPixel [0] = Interpolate_2(pixel5, pixel8, 3, 1, 2); break; case 223: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 2, 1, 1, 2); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel7, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 2, 1, 1, 2); else dstCurLineNextPixel [0] = pixel5; break; case 247: dstRowPtr[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; dstCurLine[0] = Interpolate_2(pixel5, pixel4, 3, 1, 2); if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; case 255: if (gray4 == gray2) dstRowPtr[0] = Interpolate_3(pixel5, pixel4, pixel2, 14, 1, 1, 4); else dstRowPtr[0] = pixel5; if (gray2 == gray6) dstRowPtr[1] = Interpolate_3(pixel5, pixel2, pixel6, 14, 1, 1, 4); else dstRowPtr[1] = pixel5; if (gray8 == gray4) dstCurLine[0] = Interpolate_3(pixel5, pixel8, pixel4, 14, 1, 1, 4); else dstCurLine[0] = pixel5; if (gray6 == gray8) dstCurLineNextPixel [0] = Interpolate_3(pixel5, pixel6, pixel8, 14, 1, 1, 4); else dstCurLineNextPixel [0] = pixel5; break; default: break; } srcRowPtr++; dstRowPtr += step; } } }
本代码仅支持4通道32位,若1通道以及3通道,可参考改动之。
也不是很麻烦,代码也是挺简单的,虽然有点长,懒得写注释了,感兴趣的可以看看官方的代码。
俺这代码主要是做了一些算法上的简单优化。
好久没发博文里,上来冒个泡。不喜请喷。
俺的联系方式如下:
邮箱: gaozhihan@vip.qq.com
QQ:200759103
联系我时请说明来意,不然一律忽略,谢谢。