GenuineSounds

HQ2X Filter

Jul 23rd, 2011
240
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 109.97 KB | None | 0 0
  1. import java.awt.image.BufferedImage;
  2.  
  3. public class TextureFilter {
  4.  
  5.         private static boolean lutsOk = false;
  6.         private static int LUT16to32[];
  7.         private static int RGBtoYUV[];
  8.         private static int YUV1, YUV2;
  9.         private static final int Ymask = 0x00FF0000;
  10.         private static final int Umask = 0x0000FF00;
  11.         private static final int Vmask = 0x000000FF;
  12.         private static final int trY   = 0x00300000;
  13.         private static final int trU   = 0x00000700;
  14.         private static final int trV   = 0x00000006;
  15.        
  16.         private static int Interp1(int c1, int c2)
  17.         {
  18.           return ((c1*3+c2) >> 2)|0xFF000000;
  19.         }
  20.        
  21.         private static int Interp2(int c1, int c2, int c3)
  22.         {
  23.           return ((c1*2+c2+c3) >> 2)|0xFF000000;
  24.         }
  25.        
  26.         @SuppressWarnings("unused")
  27.         private static int Interp5(int c1, int c2)
  28.         {
  29.           return ((c1+c2) >> 1)|0xFF000000;
  30.         }
  31.  
  32.         private static int Interp6(int c1, int c2, int c3)
  33.         {
  34.           return (((((c1 & 0x00FF00)*5 + (c2 & 0x00FF00)*2 + (c3 & 0x00FF00) ) & 0x0007F800) +
  35.                          (((c1 & 0xFF00FF)*5 + (c2 & 0xFF00FF)*2 + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3)|0xFF000000;
  36.         }
  37.  
  38.         private static int Interp7(int c1, int c2, int c3)
  39.         {
  40.           return (((((c1 & 0x00FF00)*6 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x0007F800) +
  41.                          (((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3)|0xFF000000;
  42.         }
  43.  
  44.         private static int Interp9(int c1, int c2, int c3)
  45.         {
  46.           return (((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*3 ) & 0x0007F800) +
  47.                          (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*3 ) & 0x07F807F8)) >> 3)|0xFF000000;
  48.         }
  49.  
  50.         private static int Interp10(int c1, int c2, int c3)
  51.         {
  52.           return (((((c1 & 0x00FF00)*14 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x000FF000) +
  53.                          (((c1 & 0xFF00FF)*14 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x0FF00FF0)) >> 4)|0xFF000000;
  54.         }
  55.        
  56.         private static boolean Diff(int w1, int w2)
  57.         {
  58.           YUV1 = RGBtoYUV[w1];
  59.           YUV2 = RGBtoYUV[w2];
  60.           return ( ( Math.abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
  61.                    ( Math.abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
  62.                    ( Math.abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) );
  63.         }
  64.        
  65.         private static void hq2x_32(int[] in, int[] out, int Xres, int Yres)
  66.         {
  67.           int  i, j, k;
  68.           int  outX = 0;
  69.           int  outY = 0;
  70.           int  prevline, nextline;
  71.           int  w[] = new int[10];
  72.           int  c[] = new int[10];
  73.          
  74.           //   +----+----+----+
  75.           //   |    |    |    |
  76.           //   | w1 | w2 | w3 |
  77.           //   +----+----+----+
  78.           //   |    |    |    |
  79.           //   | w4 | w5 | w6 |
  80.           //   +----+----+----+
  81.           //   |    |    |    |
  82.           //   | w7 | w8 | w9 |
  83.           //   +----+----+----+
  84.          
  85.           for (j=0; j<Yres; j++)
  86.           {
  87.             if (j>0)      prevline = -1; else prevline = 0;
  88.             if (j<Yres-1) nextline =  1; else nextline = 0;
  89.            
  90.             outX = 0;
  91.  
  92.             for (i=0; i<Xres; i++)
  93.             {
  94.               w[2] = RGB8888toRGB565(in[i + (j+prevline)*Xres]);
  95.               w[5] = RGB8888toRGB565(in[i + j*Xres]);
  96.               w[8] = RGB8888toRGB565(in[i + (j+nextline)*Xres]);
  97.  
  98.               if (i>0)
  99.               {
  100.                 w[1] = RGB8888toRGB565(in[i-1 + (j+prevline)*Xres]);
  101.                 w[4] = RGB8888toRGB565(in[i-1 + j*Xres]);
  102.                 w[7] = RGB8888toRGB565(in[i-1 + (j+nextline)*Xres]);
  103.               }
  104.               else
  105.               {
  106.                 w[1] = w[2];
  107.                 w[4] = w[5];
  108.                 w[7] = w[8];
  109.               }
  110.  
  111.               if (i<Xres-1)
  112.               {
  113.                 w[3] = RGB8888toRGB565(in[i+1 + (j+prevline)*Xres]);
  114.                 w[6] = RGB8888toRGB565(in[i+1 + j*Xres]);
  115.                 w[9] = RGB8888toRGB565(in[i+1 + (j+nextline)*Xres]);
  116.               }
  117.               else
  118.               {
  119.                 w[3] = w[2];
  120.                 w[6] = w[5];
  121.                 w[9] = w[8];
  122.               }
  123.  
  124.               int pattern = 0;
  125.               int flag = 1;
  126.              
  127.               YUV1 = RGBtoYUV[w[5]];
  128.  
  129.               for (k=1; k<=9; k++)
  130.               {
  131.                 if (k==5) continue;
  132.  
  133.                 if ( w[k] != w[5] )
  134.                 {
  135.                   YUV2 = RGBtoYUV[w[k]];
  136.                   if ( ( Math.abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
  137.                        ( Math.abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
  138.                        ( Math.abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
  139.                     pattern |= flag;
  140.                 }
  141.                 flag <<= 1;
  142.               }
  143.  
  144.               for (k=1; k<=9; k++){
  145.                 c[k] = LUT16to32[w[k]];
  146.               }
  147.              
  148.               switch (pattern)
  149.               {
  150.                 case 0:
  151.                 case 1:
  152.                 case 4:
  153.                 case 32:
  154.                 case 128:
  155.                 case 5:
  156.                 case 132:
  157.                 case 160:
  158.                 case 33:
  159.                 case 129:
  160.                 case 36:
  161.                 case 133:
  162.                 case 164:
  163.                 case 161:
  164.                 case 37:
  165.                 case 165:
  166.                 {
  167.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  168.               out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  169.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  170.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  171.                   break;
  172.                 }
  173.                 case 2:
  174.                 case 34:
  175.                 case 130:
  176.                 case 162:
  177.                 {
  178.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  179.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  180.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  181.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  182.                   break;
  183.                 }
  184.                 case 16:
  185.                 case 17:
  186.                 case 48:
  187.                 case 49:
  188.                 {
  189.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  190.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  191.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  192.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  193.                   break;
  194.                 }
  195.                 case 64:
  196.                 case 65:
  197.                 case 68:
  198.                 case 69:
  199.                 {
  200.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  201.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  202.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  203.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  204.                   break;
  205.                 }
  206.                 case 8:
  207.                 case 12:
  208.                 case 136:
  209.                 case 140:
  210.                 {
  211.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  212.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  213.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  214.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  215.                   break;
  216.                 }
  217.                 case 3:
  218.                 case 35:
  219.                 case 131:
  220.                 case 163:
  221.                 {
  222.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  223.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  224.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  225.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  226.                   break;
  227.                 }
  228.                 case 6:
  229.                 case 38:
  230.                 case 134:
  231.                 case 166:
  232.                 {
  233.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  234.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  235.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  236.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  237.                   break;
  238.                 }
  239.                 case 20:
  240.                 case 21:
  241.                 case 52:
  242.                 case 53:
  243.                 {
  244.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  245.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  246.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  247.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  248.                   break;
  249.                 }
  250.                 case 144:
  251.                 case 145:
  252.                 case 176:
  253.                 case 177:
  254.                 {
  255.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  256.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  257.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  258.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  259.                   break;
  260.                 }
  261.                 case 192:
  262.                 case 193:
  263.                 case 196:
  264.                 case 197:
  265.                 {
  266.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  267.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  268.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  269.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  270.                   break;
  271.                 }
  272.                 case 96:
  273.                 case 97:
  274.                 case 100:
  275.                 case 101:
  276.                 {
  277.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  278.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  279.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  280.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  281.                   break;
  282.                 }
  283.                 case 40:
  284.                 case 44:
  285.                 case 168:
  286.                 case 172:
  287.                 {
  288.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  289.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  290.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  291.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  292.                   break;
  293.                 }
  294.                 case 9:
  295.                 case 13:
  296.                 case 137:
  297.                 case 141:
  298.                 {
  299.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  300.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  301.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  302.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  303.                   break;
  304.                 }
  305.                 case 18:
  306.                 case 50:
  307.                 {
  308.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  309.                   if (Diff(w[2], w[6]))
  310.                   {
  311.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  312.                   }
  313.                   else
  314.                   {
  315.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  316.                   }
  317.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  318.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  319.                   break;
  320.                 }
  321.                 case 80:
  322.                 case 81:
  323.                 {
  324.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  325.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  326.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  327.                   if (Diff(w[6], w[8]))
  328.                   {
  329.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  330.                   }
  331.                   else
  332.                   {
  333.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  334.                   }
  335.                   break;
  336.                 }
  337.                 case 72:
  338.                 case 76:
  339.                 {
  340.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  341.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  342.                   if (Diff(w[8], w[4]))
  343.                   {
  344.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  345.                   }
  346.                   else
  347.                   {
  348.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  349.                   }
  350.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  351.                   break;
  352.                 }
  353.                 case 10:
  354.                 case 138:
  355.                 {
  356.                   if (Diff(w[4], w[2]))
  357.                   {
  358.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  359.                   }
  360.                   else
  361.                   {
  362.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  363.                   }
  364.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  365.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  366.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  367.                   break;
  368.                 }
  369.                 case 66:
  370.                 {
  371.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  372.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  373.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  374.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  375.                   break;
  376.                 }
  377.                 case 24:
  378.                 {
  379.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  380.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  381.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  382.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  383.                   break;
  384.                 }
  385.                 case 7:
  386.                 case 39:
  387.                 case 135:
  388.                 {
  389.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  390.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  391.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  392.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  393.                   break;
  394.                 }
  395.                 case 148:
  396.                 case 149:
  397.                 case 180:
  398.                 {
  399.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  400.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  401.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  402.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  403.                   break;
  404.                 }
  405.                 case 224:
  406.                 case 228:
  407.                 case 225:
  408.                 {
  409.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  410.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  411.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  412.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  413.                   break;
  414.                 }
  415.                 case 41:
  416.                 case 169:
  417.                 case 45:
  418.                 {
  419.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  420.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  421.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  422.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  423.                   break;
  424.                 }
  425.                 case 22:
  426.                 case 54:
  427.                 {
  428.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  429.                   if (Diff(w[2], w[6]))
  430.                   {
  431.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  432.                   }
  433.                   else
  434.                   {
  435.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  436.                   }
  437.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  438.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  439.                   break;
  440.                 }
  441.                 case 208:
  442.                 case 209:
  443.                 {
  444.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  445.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  446.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  447.                   if (Diff(w[6], w[8]))
  448.                   {
  449.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  450.                   }
  451.                   else
  452.                   {
  453.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  454.                   }
  455.                   break;
  456.                 }
  457.                 case 104:
  458.                 case 108:
  459.                 {
  460.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  461.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  462.                   if (Diff(w[8], w[4]))
  463.                   {
  464.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  465.                   }
  466.                   else
  467.                   {
  468.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  469.                   }
  470.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  471.                   break;
  472.                 }
  473.                 case 11:
  474.                 case 139:
  475.                 {
  476.                   if (Diff(w[4], w[2]))
  477.                   {
  478.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  479.                   }
  480.                   else
  481.                   {
  482.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  483.                   }
  484.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  485.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  486.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  487.                   break;
  488.                 }
  489.                 case 19:
  490.                 case 51:
  491.                 {
  492.                   if (Diff(w[2], w[6]))
  493.                   {
  494.                     out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  495.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  496.                   }
  497.                   else
  498.                   {
  499.                     out[outX+outY*Xres*2] = Interp6(c[5], c[2], c[4]);
  500.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  501.                   }
  502.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  503.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  504.                   break;
  505.                 }
  506.                 case 146:
  507.                 case 178:
  508.                 {
  509.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  510.                   if (Diff(w[2], w[6]))
  511.                   {
  512.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  513.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  514.                   }
  515.                   else
  516.                   {
  517.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  518.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[6], c[8]);
  519.                   }
  520.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  521.                   break;
  522.                 }
  523.                 case 84:
  524.                 case 85:
  525.                 {
  526.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  527.                   if (Diff(w[6], w[8]))
  528.                   {
  529.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  530.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  531.                   }
  532.                   else
  533.                   {
  534.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[6], c[2]);
  535.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  536.                   }
  537.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  538.                   break;
  539.                 }
  540.                 case 112:
  541.                 case 113:
  542.                 {
  543.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  544.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  545.                   if (Diff(w[6], w[8]))
  546.                   {
  547.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  548.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  549.                   }
  550.                   else
  551.                   {
  552.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[4]);
  553.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  554.                   }
  555.                   break;
  556.                 }
  557.                 case 200:
  558.                 case 204:
  559.                 {
  560.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  561.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  562.                   if (Diff(w[8], w[4]))
  563.                   {
  564.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  565.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  566.                   }
  567.                   else
  568.                   {
  569.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  570.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[6]);
  571.                   }
  572.                   break;
  573.                 }
  574.                 case 73:
  575.                 case 77:
  576.                 {
  577.                   if (Diff(w[8], w[4]))
  578.                   {
  579.                     out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  580.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  581.                   }
  582.                   else
  583.                   {
  584.                     out[outX+outY*Xres*2] = Interp6(c[5], c[4], c[2]);
  585.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  586.                   }
  587.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  588.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  589.                   break;
  590.                 }
  591.                 case 42:
  592.                 case 170:
  593.                 {
  594.                   if (Diff(w[4], w[2]))
  595.                   {
  596.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  597.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  598.                   }
  599.                   else
  600.                   {
  601.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  602.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[4], c[8]);
  603.                   }
  604.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  605.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  606.                   break;
  607.                 }
  608.                 case 14:
  609.                 case 142:
  610.                 {
  611.                   if (Diff(w[4], w[2]))
  612.                   {
  613.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  614.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  615.                   }
  616.                   else
  617.                   {
  618.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  619.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[2], c[6]);
  620.                   }
  621.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  622.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  623.                   break;
  624.                 }
  625.                 case 67:
  626.                 {
  627.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  628.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  629.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  630.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  631.                   break;
  632.                 }
  633.                 case 70:
  634.                 {
  635.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  636.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  637.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  638.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  639.                   break;
  640.                 }
  641.                 case 28:
  642.                 {
  643.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  644.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  645.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  646.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  647.                   break;
  648.                 }
  649.                 case 152:
  650.                 {
  651.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  652.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  653.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  654.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  655.                   break;
  656.                 }
  657.                 case 194:
  658.                 {
  659.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  660.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  661.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  662.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  663.                   break;
  664.                 }
  665.                 case 98:
  666.                 {
  667.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  668.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  669.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  670.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  671.                   break;
  672.                 }
  673.                 case 56:
  674.                 {
  675.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  676.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  677.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  678.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  679.                   break;
  680.                 }
  681.                 case 25:
  682.                 {
  683.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  684.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  685.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  686.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  687.                   break;
  688.                 }
  689.                 case 26:
  690.                 case 31:
  691.                 {
  692.                   if (Diff(w[4], w[2]))
  693.                   {
  694.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  695.                   }
  696.                   else
  697.                   {
  698.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  699.                   }
  700.                   if (Diff(w[2], w[6]))
  701.                   {
  702.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  703.                   }
  704.                   else
  705.                   {
  706.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  707.                   }
  708.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  709.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  710.                   break;
  711.                 }
  712.                 case 82:
  713.                 case 214:
  714.                 {
  715.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  716.                   if (Diff(w[2], w[6]))
  717.                   {
  718.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  719.                   }
  720.                   else
  721.                   {
  722.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  723.                   }
  724.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  725.                   if (Diff(w[6], w[8]))
  726.                   {
  727.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  728.                   }
  729.                   else
  730.                   {
  731.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  732.                   }
  733.                   break;
  734.                 }
  735.                 case 88:
  736.                 case 248:
  737.                 {
  738.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  739.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  740.                   if (Diff(w[8], w[4]))
  741.                   {
  742.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  743.                   }
  744.                   else
  745.                   {
  746.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  747.                   }
  748.                   if (Diff(w[6], w[8]))
  749.                   {
  750.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  751.                   }
  752.                   else
  753.                   {
  754.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  755.                   }
  756.                   break;
  757.                 }
  758.                 case 74:
  759.                 case 107:
  760.                 {
  761.                   if (Diff(w[4], w[2]))
  762.                   {
  763.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  764.                   }
  765.                   else
  766.                   {
  767.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  768.                   }
  769.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  770.                   if (Diff(w[8], w[4]))
  771.                   {
  772.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  773.                   }
  774.                   else
  775.                   {
  776.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  777.                   }
  778.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  779.                   break;
  780.                 }
  781.                 case 27:
  782.                 {
  783.                   if (Diff(w[4], w[2]))
  784.                   {
  785.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  786.                   }
  787.                   else
  788.                   {
  789.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  790.                   }
  791.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  792.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  793.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  794.                   break;
  795.                 }
  796.                 case 86:
  797.                 {
  798.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  799.                   if (Diff(w[2], w[6]))
  800.                   {
  801.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  802.                   }
  803.                   else
  804.                   {
  805.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  806.                   }
  807.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  808.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  809.                   break;
  810.                 }
  811.                 case 216:
  812.                 {
  813.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  814.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  815.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  816.                   if (Diff(w[6], w[8]))
  817.                   {
  818.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  819.                   }
  820.                   else
  821.                   {
  822.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  823.                   }
  824.                   break;
  825.                 }
  826.                 case 106:
  827.                 {
  828.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  829.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  830.                   if (Diff(w[8], w[4]))
  831.                   {
  832.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  833.                   }
  834.                   else
  835.                   {
  836.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  837.                   }
  838.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  839.                   break;
  840.                 }
  841.                 case 30:
  842.                 {
  843.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  844.                   if (Diff(w[2], w[6]))
  845.                   {
  846.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  847.                   }
  848.                   else
  849.                   {
  850.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  851.                   }
  852.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  853.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  854.                   break;
  855.                 }
  856.                 case 210:
  857.                 {
  858.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  859.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  860.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  861.                   if (Diff(w[6], w[8]))
  862.                   {
  863.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  864.                   }
  865.                   else
  866.                   {
  867.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  868.                   }
  869.                   break;
  870.                 }
  871.                 case 120:
  872.                 {
  873.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  874.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  875.                   if (Diff(w[8], w[4]))
  876.                   {
  877.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  878.                   }
  879.                   else
  880.                   {
  881.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  882.                   }
  883.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  884.                   break;
  885.                 }
  886.                 case 75:
  887.                 {
  888.                   if (Diff(w[4], w[2]))
  889.                   {
  890.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  891.                   }
  892.                   else
  893.                   {
  894.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  895.                   }
  896.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  897.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  898.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  899.                   break;
  900.                 }
  901.                 case 29:
  902.                 {
  903.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  904.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  905.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  906.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  907.                   break;
  908.                 }
  909.                 case 198:
  910.                 {
  911.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  912.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  913.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  914.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  915.                   break;
  916.                 }
  917.                 case 184:
  918.                 {
  919.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  920.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  921.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  922.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  923.                   break;
  924.                 }
  925.                 case 99:
  926.                 {
  927.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  928.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  929.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  930.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  931.                   break;
  932.                 }
  933.                 case 57:
  934.                 {
  935.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  936.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  937.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  938.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  939.                   break;
  940.                 }
  941.                 case 71:
  942.                 {
  943.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  944.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  945.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  946.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  947.                   break;
  948.                 }
  949.                 case 156:
  950.                 {
  951.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  952.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  953.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  954.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  955.                   break;
  956.                 }
  957.                 case 226:
  958.                 {
  959.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  960.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  961.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  962.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  963.                   break;
  964.                 }
  965.                 case 60:
  966.                 {
  967.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  968.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  969.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  970.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  971.                   break;
  972.                 }
  973.                 case 195:
  974.                 {
  975.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  976.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  977.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  978.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  979.                   break;
  980.                 }
  981.                 case 102:
  982.                 {
  983.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  984.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  985.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  986.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  987.                   break;
  988.                 }
  989.                 case 153:
  990.                 {
  991.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  992.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  993.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  994.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  995.                   break;
  996.                 }
  997.                 case 58:
  998.                 {
  999.                   if (Diff(w[4], w[2]))
  1000.                   {
  1001.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1002.                   }
  1003.                   else
  1004.                   {
  1005.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1006.                   }
  1007.                   if (Diff(w[2], w[6]))
  1008.                   {
  1009.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1010.                   }
  1011.                   else
  1012.                   {
  1013.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1014.                   }
  1015.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1016.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  1017.                   break;
  1018.                 }
  1019.                 case 83:
  1020.                 {
  1021.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1022.                   if (Diff(w[2], w[6]))
  1023.                   {
  1024.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1025.                   }
  1026.                   else
  1027.                   {
  1028.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1029.                   }
  1030.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  1031.                   if (Diff(w[6], w[8]))
  1032.                   {
  1033.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1034.                   }
  1035.                   else
  1036.                   {
  1037.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1038.                   }
  1039.                   break;
  1040.                 }
  1041.                 case 92:
  1042.                 {
  1043.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  1044.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1045.                   if (Diff(w[8], w[4]))
  1046.                   {
  1047.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1048.                   }
  1049.                   else
  1050.                   {
  1051.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1052.                   }
  1053.                   if (Diff(w[6], w[8]))
  1054.                   {
  1055.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1056.                   }
  1057.                   else
  1058.                   {
  1059.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1060.                   }
  1061.                   break;
  1062.                 }
  1063.                 case 202:
  1064.                 {
  1065.                   if (Diff(w[4], w[2]))
  1066.                   {
  1067.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1068.                   }
  1069.                   else
  1070.                   {
  1071.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1072.                   }
  1073.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  1074.                   if (Diff(w[8], w[4]))
  1075.                   {
  1076.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1077.                   }
  1078.                   else
  1079.                   {
  1080.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1081.                   }
  1082.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1083.                   break;
  1084.                 }
  1085.                 case 78:
  1086.                 {
  1087.                   if (Diff(w[4], w[2]))
  1088.                   {
  1089.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1090.                   }
  1091.                   else
  1092.                   {
  1093.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1094.                   }
  1095.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1096.                   if (Diff(w[8], w[4]))
  1097.                   {
  1098.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1099.                   }
  1100.                   else
  1101.                   {
  1102.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1103.                   }
  1104.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  1105.                   break;
  1106.                 }
  1107.                 case 154:
  1108.                 {
  1109.                   if (Diff(w[4], w[2]))
  1110.                   {
  1111.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1112.                   }
  1113.                   else
  1114.                   {
  1115.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1116.                   }
  1117.                   if (Diff(w[2], w[6]))
  1118.                   {
  1119.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1120.                   }
  1121.                   else
  1122.                   {
  1123.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1124.                   }
  1125.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  1126.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1127.                   break;
  1128.                 }
  1129.                 case 114:
  1130.                 {
  1131.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  1132.                   if (Diff(w[2], w[6]))
  1133.                   {
  1134.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1135.                   }
  1136.                   else
  1137.                   {
  1138.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1139.                   }
  1140.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1141.                   if (Diff(w[6], w[8]))
  1142.                   {
  1143.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1144.                   }
  1145.                   else
  1146.                   {
  1147.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1148.                   }
  1149.                   break;
  1150.                 }
  1151.                 case 89:
  1152.                 {
  1153.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1154.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  1155.                   if (Diff(w[8], w[4]))
  1156.                   {
  1157.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1158.                   }
  1159.                   else
  1160.                   {
  1161.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1162.                   }
  1163.                   if (Diff(w[6], w[8]))
  1164.                   {
  1165.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1166.                   }
  1167.                   else
  1168.                   {
  1169.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1170.                   }
  1171.                   break;
  1172.                 }
  1173.                 case 90:
  1174.                 {
  1175.                   if (Diff(w[4], w[2]))
  1176.                   {
  1177.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1178.                   }
  1179.                   else
  1180.                   {
  1181.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1182.                   }
  1183.                   if (Diff(w[2], w[6]))
  1184.                   {
  1185.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1186.                   }
  1187.                   else
  1188.                   {
  1189.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1190.                   }
  1191.                   if (Diff(w[8], w[4]))
  1192.                   {
  1193.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1194.                   }
  1195.                   else
  1196.                   {
  1197.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1198.                   }
  1199.                   if (Diff(w[6], w[8]))
  1200.                   {
  1201.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1202.                   }
  1203.                   else
  1204.                   {
  1205.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1206.                   }
  1207.                   break;
  1208.                 }
  1209.                 case 55:
  1210.                 case 23:
  1211.                 {
  1212.                   if (Diff(w[2], w[6]))
  1213.                   {
  1214.                     out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1215.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1216.                   }
  1217.                   else
  1218.                   {
  1219.                     out[outX+outY*Xres*2] = Interp6(c[5], c[2], c[4]);
  1220.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  1221.                   }
  1222.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1223.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  1224.                   break;
  1225.                 }
  1226.                 case 182:
  1227.                 case 150:
  1228.                 {
  1229.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  1230.                   if (Diff(w[2], w[6]))
  1231.                   {
  1232.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1233.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1234.                   }
  1235.                   else
  1236.                   {
  1237.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  1238.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[6], c[8]);
  1239.                   }
  1240.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1241.                   break;
  1242.                 }
  1243.                 case 213:
  1244.                 case 212:
  1245.                 {
  1246.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1247.                   if (Diff(w[6], w[8]))
  1248.                   {
  1249.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1250.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1251.                   }
  1252.                   else
  1253.                   {
  1254.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[6], c[2]);
  1255.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  1256.                   }
  1257.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  1258.                   break;
  1259.                 }
  1260.                 case 241:
  1261.                 case 240:
  1262.                 {
  1263.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1264.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  1265.                   if (Diff(w[6], w[8]))
  1266.                   {
  1267.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1268.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1269.                   }
  1270.                   else
  1271.                   {
  1272.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[4]);
  1273.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  1274.                   }
  1275.                   break;
  1276.                 }
  1277.                 case 236:
  1278.                 case 232:
  1279.                 {
  1280.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  1281.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1282.                   if (Diff(w[8], w[4]))
  1283.                   {
  1284.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1285.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1286.                   }
  1287.                   else
  1288.                   {
  1289.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  1290.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[6]);
  1291.                   }
  1292.                   break;
  1293.                 }
  1294.                 case 109:
  1295.                 case 105:
  1296.                 {
  1297.                   if (Diff(w[8], w[4]))
  1298.                   {
  1299.                     out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1300.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1301.                   }
  1302.                   else
  1303.                   {
  1304.                     out[outX+outY*Xres*2] = Interp6(c[5], c[4], c[2]);
  1305.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  1306.                   }
  1307.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1308.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  1309.                   break;
  1310.                 }
  1311.                 case 171:
  1312.                 case 43:
  1313.                 {
  1314.                   if (Diff(w[4], w[2]))
  1315.                   {
  1316.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1317.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1318.                   }
  1319.                   else
  1320.                   {
  1321.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  1322.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[4], c[8]);
  1323.                   }
  1324.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  1325.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1326.                   break;
  1327.                 }
  1328.                 case 143:
  1329.                 case 15:
  1330.                 {
  1331.                   if (Diff(w[4], w[2]))
  1332.                   {
  1333.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1334.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1335.                   }
  1336.                   else
  1337.                   {
  1338.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  1339.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[2], c[6]);
  1340.                   }
  1341.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  1342.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1343.                   break;
  1344.                 }
  1345.                 case 124:
  1346.                 {
  1347.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  1348.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1349.                   if (Diff(w[8], w[4]))
  1350.                   {
  1351.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1352.                   }
  1353.                   else
  1354.                   {
  1355.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1356.                   }
  1357.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1358.                   break;
  1359.                 }
  1360.                 case 203:
  1361.                 {
  1362.                   if (Diff(w[4], w[2]))
  1363.                   {
  1364.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1365.                   }
  1366.                   else
  1367.                   {
  1368.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1369.                   }
  1370.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  1371.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1372.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1373.                   break;
  1374.                 }
  1375.                 case 62:
  1376.                 {
  1377.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1378.                   if (Diff(w[2], w[6]))
  1379.                   {
  1380.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1381.                   }
  1382.                   else
  1383.                   {
  1384.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1385.                   }
  1386.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1387.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  1388.                   break;
  1389.                 }
  1390.                 case 211:
  1391.                 {
  1392.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1393.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1394.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  1395.                   if (Diff(w[6], w[8]))
  1396.                   {
  1397.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1398.                   }
  1399.                   else
  1400.                   {
  1401.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1402.                   }
  1403.                   break;
  1404.                 }
  1405.                 case 118:
  1406.                 {
  1407.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  1408.                   if (Diff(w[2], w[6]))
  1409.                   {
  1410.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1411.                   }
  1412.                   else
  1413.                   {
  1414.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1415.                   }
  1416.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1417.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1418.                   break;
  1419.                 }
  1420.                 case 217:
  1421.                 {
  1422.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1423.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  1424.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1425.                   if (Diff(w[6], w[8]))
  1426.                   {
  1427.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1428.                   }
  1429.                   else
  1430.                   {
  1431.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1432.                   }
  1433.                   break;
  1434.                 }
  1435.                 case 110:
  1436.                 {
  1437.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1438.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1439.                   if (Diff(w[8], w[4]))
  1440.                   {
  1441.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1442.                   }
  1443.                   else
  1444.                   {
  1445.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1446.                   }
  1447.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  1448.                   break;
  1449.                 }
  1450.                 case 155:
  1451.                 {
  1452.                   if (Diff(w[4], w[2]))
  1453.                   {
  1454.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1455.                   }
  1456.                   else
  1457.                   {
  1458.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1459.                   }
  1460.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1461.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  1462.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1463.                   break;
  1464.                 }
  1465.                 case 188:
  1466.                 {
  1467.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  1468.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1469.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1470.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1471.                   break;
  1472.                 }
  1473.                 case 185:
  1474.                 {
  1475.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1476.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  1477.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1478.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1479.                   break;
  1480.                 }
  1481.                 case 61:
  1482.                 {
  1483.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1484.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1485.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1486.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  1487.                   break;
  1488.                 }
  1489.                 case 157:
  1490.                 {
  1491.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1492.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1493.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  1494.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1495.                   break;
  1496.                 }
  1497.                 case 103:
  1498.                 {
  1499.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1500.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1501.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1502.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  1503.                   break;
  1504.                 }
  1505.                 case 227:
  1506.                 {
  1507.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1508.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  1509.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1510.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1511.                   break;
  1512.                 }
  1513.                 case 230:
  1514.                 {
  1515.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  1516.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1517.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1518.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1519.                   break;
  1520.                 }
  1521.                 case 199:
  1522.                 {
  1523.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1524.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1525.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  1526.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1527.                   break;
  1528.                 }
  1529.                 case 220:
  1530.                 {
  1531.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  1532.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1533.                   if (Diff(w[8], w[4]))
  1534.                   {
  1535.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1536.                   }
  1537.                   else
  1538.                   {
  1539.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1540.                   }
  1541.                   if (Diff(w[6], w[8]))
  1542.                   {
  1543.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1544.                   }
  1545.                   else
  1546.                   {
  1547.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1548.                   }
  1549.                   break;
  1550.                 }
  1551.                 case 158:
  1552.                 {
  1553.                   if (Diff(w[4], w[2]))
  1554.                   {
  1555.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1556.                   }
  1557.                   else
  1558.                   {
  1559.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1560.                   }
  1561.                   if (Diff(w[2], w[6]))
  1562.                   {
  1563.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1564.                   }
  1565.                   else
  1566.                   {
  1567.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1568.                   }
  1569.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  1570.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1571.                   break;
  1572.                 }
  1573.                 case 234:
  1574.                 {
  1575.                   if (Diff(w[4], w[2]))
  1576.                   {
  1577.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1578.                   }
  1579.                   else
  1580.                   {
  1581.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1582.                   }
  1583.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  1584.                   if (Diff(w[8], w[4]))
  1585.                   {
  1586.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1587.                   }
  1588.                   else
  1589.                   {
  1590.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1591.                   }
  1592.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1593.                   break;
  1594.                 }
  1595.                 case 242:
  1596.                 {
  1597.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  1598.                   if (Diff(w[2], w[6]))
  1599.                   {
  1600.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1601.                   }
  1602.                   else
  1603.                   {
  1604.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1605.                   }
  1606.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1607.                   if (Diff(w[6], w[8]))
  1608.                   {
  1609.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1610.                   }
  1611.                   else
  1612.                   {
  1613.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1614.                   }
  1615.                   break;
  1616.                 }
  1617.                 case 59:
  1618.                 {
  1619.                   if (Diff(w[4], w[2]))
  1620.                   {
  1621.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1622.                   }
  1623.                   else
  1624.                   {
  1625.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1626.                   }
  1627.                   if (Diff(w[2], w[6]))
  1628.                   {
  1629.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1630.                   }
  1631.                   else
  1632.                   {
  1633.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1634.                   }
  1635.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1636.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  1637.                   break;
  1638.                 }
  1639.                 case 121:
  1640.                 {
  1641.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1642.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  1643.                   if (Diff(w[8], w[4]))
  1644.                   {
  1645.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1646.                   }
  1647.                   else
  1648.                   {
  1649.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1650.                   }
  1651.                   if (Diff(w[6], w[8]))
  1652.                   {
  1653.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1654.                   }
  1655.                   else
  1656.                   {
  1657.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1658.                   }
  1659.                   break;
  1660.                 }
  1661.                 case 87:
  1662.                 {
  1663.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1664.                   if (Diff(w[2], w[6]))
  1665.                   {
  1666.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1667.                   }
  1668.                   else
  1669.                   {
  1670.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1671.                   }
  1672.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  1673.                   if (Diff(w[6], w[8]))
  1674.                   {
  1675.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1676.                   }
  1677.                   else
  1678.                   {
  1679.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1680.                   }
  1681.                   break;
  1682.                 }
  1683.                 case 79:
  1684.                 {
  1685.                   if (Diff(w[4], w[2]))
  1686.                   {
  1687.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1688.                   }
  1689.                   else
  1690.                   {
  1691.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1692.                   }
  1693.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1694.                   if (Diff(w[8], w[4]))
  1695.                   {
  1696.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1697.                   }
  1698.                   else
  1699.                   {
  1700.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1701.                   }
  1702.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  1703.                   break;
  1704.                 }
  1705.                 case 122:
  1706.                 {
  1707.                   if (Diff(w[4], w[2]))
  1708.                   {
  1709.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1710.                   }
  1711.                   else
  1712.                   {
  1713.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1714.                   }
  1715.                   if (Diff(w[2], w[6]))
  1716.                   {
  1717.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1718.                   }
  1719.                   else
  1720.                   {
  1721.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1722.                   }
  1723.                   if (Diff(w[8], w[4]))
  1724.                   {
  1725.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1726.                   }
  1727.                   else
  1728.                   {
  1729.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1730.                   }
  1731.                   if (Diff(w[6], w[8]))
  1732.                   {
  1733.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1734.                   }
  1735.                   else
  1736.                   {
  1737.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1738.                   }
  1739.                   break;
  1740.                 }
  1741.                 case 94:
  1742.                 {
  1743.                   if (Diff(w[4], w[2]))
  1744.                   {
  1745.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1746.                   }
  1747.                   else
  1748.                   {
  1749.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1750.                   }
  1751.                   if (Diff(w[2], w[6]))
  1752.                   {
  1753.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  1754.                   }
  1755.                   else
  1756.                   {
  1757.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1758.                   }
  1759.                   if (Diff(w[8], w[4]))
  1760.                   {
  1761.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1762.                   }
  1763.                   else
  1764.                   {
  1765.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1766.                   }
  1767.                   if (Diff(w[6], w[8]))
  1768.                   {
  1769.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1770.                   }
  1771.                   else
  1772.                   {
  1773.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1774.                   }
  1775.                   break;
  1776.                 }
  1777.                 case 218:
  1778.                 {
  1779.                   if (Diff(w[4], w[2]))
  1780.                   {
  1781.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1782.                   }
  1783.                   else
  1784.                   {
  1785.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1786.                   }
  1787.                   if (Diff(w[2], w[6]))
  1788.                   {
  1789.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1790.                   }
  1791.                   else
  1792.                   {
  1793.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1794.                   }
  1795.                   if (Diff(w[8], w[4]))
  1796.                   {
  1797.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1798.                   }
  1799.                   else
  1800.                   {
  1801.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1802.                   }
  1803.                   if (Diff(w[6], w[8]))
  1804.                   {
  1805.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  1806.                   }
  1807.                   else
  1808.                   {
  1809.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1810.                   }
  1811.                   break;
  1812.                 }
  1813.                 case 91:
  1814.                 {
  1815.                   if (Diff(w[4], w[2]))
  1816.                   {
  1817.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  1818.                   }
  1819.                   else
  1820.                   {
  1821.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1822.                   }
  1823.                   if (Diff(w[2], w[6]))
  1824.                   {
  1825.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1826.                   }
  1827.                   else
  1828.                   {
  1829.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1830.                   }
  1831.                   if (Diff(w[8], w[4]))
  1832.                   {
  1833.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1834.                   }
  1835.                   else
  1836.                   {
  1837.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1838.                   }
  1839.                   if (Diff(w[6], w[8]))
  1840.                   {
  1841.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1842.                   }
  1843.                   else
  1844.                   {
  1845.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1846.                   }
  1847.                   break;
  1848.                 }
  1849.                 case 229:
  1850.                 {
  1851.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1852.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1853.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1854.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1855.                   break;
  1856.                 }
  1857.                 case 167:
  1858.                 {
  1859.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1860.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1861.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1862.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1863.                   break;
  1864.                 }
  1865.                 case 173:
  1866.                 {
  1867.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1868.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1869.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1870.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1871.                   break;
  1872.                 }
  1873.                 case 181:
  1874.                 {
  1875.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  1876.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1877.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  1878.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1879.                   break;
  1880.                 }
  1881.                 case 186:
  1882.                 {
  1883.                   if (Diff(w[4], w[2]))
  1884.                   {
  1885.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1886.                   }
  1887.                   else
  1888.                   {
  1889.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1890.                   }
  1891.                   if (Diff(w[2], w[6]))
  1892.                   {
  1893.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1894.                   }
  1895.                   else
  1896.                   {
  1897.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1898.                   }
  1899.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1900.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1901.                   break;
  1902.                 }
  1903.                 case 115:
  1904.                 {
  1905.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  1906.                   if (Diff(w[2], w[6]))
  1907.                   {
  1908.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  1909.                   }
  1910.                   else
  1911.                   {
  1912.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  1913.                   }
  1914.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  1915.                   if (Diff(w[6], w[8]))
  1916.                   {
  1917.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1918.                   }
  1919.                   else
  1920.                   {
  1921.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1922.                   }
  1923.                   break;
  1924.                 }
  1925.                 case 93:
  1926.                 {
  1927.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1928.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  1929.                   if (Diff(w[8], w[4]))
  1930.                   {
  1931.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1932.                   }
  1933.                   else
  1934.                   {
  1935.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1936.                   }
  1937.                   if (Diff(w[6], w[8]))
  1938.                   {
  1939.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  1940.                   }
  1941.                   else
  1942.                   {
  1943.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  1944.                   }
  1945.                   break;
  1946.                 }
  1947.                 case 206:
  1948.                 {
  1949.                   if (Diff(w[4], w[2]))
  1950.                   {
  1951.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1952.                   }
  1953.                   else
  1954.                   {
  1955.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1956.                   }
  1957.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1958.                   if (Diff(w[8], w[4]))
  1959.                   {
  1960.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1961.                   }
  1962.                   else
  1963.                   {
  1964.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1965.                   }
  1966.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1967.                   break;
  1968.                 }
  1969.                 case 205:
  1970.                 case 201:
  1971.                 {
  1972.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  1973.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  1974.                   if (Diff(w[8], w[4]))
  1975.                   {
  1976.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  1977.                   }
  1978.                   else
  1979.                   {
  1980.                     out[outX + (outY+1)*Xres*2] = Interp7(c[5], c[8], c[4]);
  1981.                   }
  1982.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  1983.                   break;
  1984.                 }
  1985.                 case 174:
  1986.                 case 46:
  1987.                 {
  1988.                   if (Diff(w[4], w[2]))
  1989.                   {
  1990.                     out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  1991.                   }
  1992.                   else
  1993.                   {
  1994.                     out[outX+outY*Xres*2] = Interp7(c[5], c[4], c[2]);
  1995.                   }
  1996.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  1997.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  1998.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  1999.                   break;
  2000.                 }
  2001.                 case 179:
  2002.                 case 147:
  2003.                 {
  2004.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2005.                   if (Diff(w[2], w[6]))
  2006.                   {
  2007.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2008.                   }
  2009.                   else
  2010.                   {
  2011.                     out[outX+1+outY*Xres*2] = Interp7(c[5], c[2], c[6]);
  2012.                   }
  2013.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2014.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2015.                   break;
  2016.                 }
  2017.                 case 117:
  2018.                 case 116:
  2019.                 {
  2020.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2021.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2022.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2023.                   if (Diff(w[6], w[8]))
  2024.                   {
  2025.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2026.                   }
  2027.                   else
  2028.                   {
  2029.                     out[outX+1 + (outY+1)*Xres*2] = Interp7(c[5], c[6], c[8]);
  2030.                   }
  2031.                   break;
  2032.                 }
  2033.                 case 189:
  2034.                 {
  2035.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2036.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2037.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2038.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2039.                   break;
  2040.                 }
  2041.                 case 231:
  2042.                 {
  2043.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2044.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2045.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2046.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2047.                   break;
  2048.                 }
  2049.                 case 126:
  2050.                 {
  2051.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2052.                   if (Diff(w[2], w[6]))
  2053.                   {
  2054.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2055.                   }
  2056.                   else
  2057.                   {
  2058.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2059.                   }
  2060.                   if (Diff(w[8], w[4]))
  2061.                   {
  2062.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2063.                   }
  2064.                   else
  2065.                   {
  2066.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2067.                   }
  2068.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2069.                   break;
  2070.                 }
  2071.                 case 219:
  2072.                 {
  2073.                   if (Diff(w[4], w[2]))
  2074.                   {
  2075.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2076.                   }
  2077.                   else
  2078.                   {
  2079.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2080.                   }
  2081.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2082.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2083.                   if (Diff(w[6], w[8]))
  2084.                   {
  2085.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2086.                   }
  2087.                   else
  2088.                   {
  2089.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2090.                   }
  2091.                   break;
  2092.                 }
  2093.                 case 125:
  2094.                 {
  2095.                   if (Diff(w[8], w[4]))
  2096.                   {
  2097.                     out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2098.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2099.                   }
  2100.                   else
  2101.                   {
  2102.                     out[outX+outY*Xres*2] = Interp6(c[5], c[4], c[2]);
  2103.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  2104.                   }
  2105.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2106.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2107.                   break;
  2108.                 }
  2109.                 case 221:
  2110.                 {
  2111.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2112.                   if (Diff(w[6], w[8]))
  2113.                   {
  2114.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2115.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2116.                   }
  2117.                   else
  2118.                   {
  2119.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[6], c[2]);
  2120.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  2121.                   }
  2122.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2123.                   break;
  2124.                 }
  2125.                 case 207:
  2126.                 {
  2127.                   if (Diff(w[4], w[2]))
  2128.                   {
  2129.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2130.                     out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2131.                   }
  2132.                   else
  2133.                   {
  2134.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  2135.                     out[outX+1+outY*Xres*2] = Interp6(c[5], c[2], c[6]);
  2136.                   }
  2137.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2138.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2139.                   break;
  2140.                 }
  2141.                 case 238:
  2142.                 {
  2143.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2144.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2145.                   if (Diff(w[8], w[4]))
  2146.                   {
  2147.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2148.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2149.                   }
  2150.                   else
  2151.                   {
  2152.                     out[outX + (outY+1)*Xres*2] = Interp9(c[5], c[8], c[4]);
  2153.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[6]);
  2154.                   }
  2155.                   break;
  2156.                 }
  2157.                 case 190:
  2158.                 {
  2159.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2160.                   if (Diff(w[2], w[6]))
  2161.                   {
  2162.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2163.                     out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2164.                   }
  2165.                   else
  2166.                   {
  2167.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  2168.                     out[outX+1 + (outY+1)*Xres*2] = Interp6(c[5], c[6], c[8]);
  2169.                   }
  2170.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2171.                   break;
  2172.                 }
  2173.                 case 187:
  2174.                 {
  2175.                   if (Diff(w[4], w[2]))
  2176.                   {
  2177.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2178.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2179.                   }
  2180.                   else
  2181.                   {
  2182.                     out[outX+outY*Xres*2] = Interp9(c[5], c[4], c[2]);
  2183.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[4], c[8]);
  2184.                   }
  2185.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2186.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2187.                   break;
  2188.                 }
  2189.                 case 243:
  2190.                 {
  2191.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2192.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2193.                   if (Diff(w[6], w[8]))
  2194.                   {
  2195.                     out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2196.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2197.                   }
  2198.                   else
  2199.                   {
  2200.                     out[outX + (outY+1)*Xres*2] = Interp6(c[5], c[8], c[4]);
  2201.                     out[outX+1 + (outY+1)*Xres*2] = Interp9(c[5], c[6], c[8]);
  2202.                   }
  2203.                   break;
  2204.                 }
  2205.                 case 119:
  2206.                 {
  2207.                   if (Diff(w[2], w[6]))
  2208.                   {
  2209.                     out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2210.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2211.                   }
  2212.                   else
  2213.                   {
  2214.                     out[outX+outY*Xres*2] = Interp6(c[5], c[2], c[4]);
  2215.                     out[outX+1+outY*Xres*2] = Interp9(c[5], c[2], c[6]);
  2216.                   }
  2217.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2218.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2219.                   break;
  2220.                 }
  2221.                 case 237:
  2222.                 case 233:
  2223.                 {
  2224.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2225.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2226.                   if (Diff(w[8], w[4]))
  2227.                   {
  2228.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2229.                   }
  2230.                   else
  2231.                   {
  2232.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2233.                   }
  2234.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2235.                   break;
  2236.                 }
  2237.                 case 175:
  2238.                 case 47:
  2239.                 {
  2240.                   if (Diff(w[4], w[2]))
  2241.                   {
  2242.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2243.                   }
  2244.                   else
  2245.                   {
  2246.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2247.                   }
  2248.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2249.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2250.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2251.                   break;
  2252.                 }
  2253.                 case 183:
  2254.                 case 151:
  2255.                 {
  2256.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2257.                   if (Diff(w[2], w[6]))
  2258.                   {
  2259.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2260.                   }
  2261.                   else
  2262.                   {
  2263.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2264.                   }
  2265.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2266.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2267.                   break;
  2268.                 }
  2269.                 case 245:
  2270.                 case 244:
  2271.                 {
  2272.                   out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2273.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2274.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2275.                   if (Diff(w[6], w[8]))
  2276.                   {
  2277.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2278.                   }
  2279.                   else
  2280.                   {
  2281.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2282.                   }
  2283.                   break;
  2284.                 }
  2285.                 case 250:
  2286.                 {
  2287.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2288.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2289.                   if (Diff(w[8], w[4]))
  2290.                   {
  2291.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2292.                   }
  2293.                   else
  2294.                   {
  2295.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2296.                   }
  2297.                   if (Diff(w[6], w[8]))
  2298.                   {
  2299.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2300.                   }
  2301.                   else
  2302.                   {
  2303.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2304.                   }
  2305.                   break;
  2306.                 }
  2307.                 case 123:
  2308.                 {
  2309.                   if (Diff(w[4], w[2]))
  2310.                   {
  2311.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2312.                   }
  2313.                   else
  2314.                   {
  2315.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2316.                   }
  2317.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2318.                   if (Diff(w[8], w[4]))
  2319.                   {
  2320.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2321.                   }
  2322.                   else
  2323.                   {
  2324.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2325.                   }
  2326.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2327.                   break;
  2328.                 }
  2329.                 case 95:
  2330.                 {
  2331.                   if (Diff(w[4], w[2]))
  2332.                   {
  2333.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2334.                   }
  2335.                   else
  2336.                   {
  2337.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2338.                   }
  2339.                   if (Diff(w[2], w[6]))
  2340.                   {
  2341.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2342.                   }
  2343.                   else
  2344.                   {
  2345.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2346.                   }
  2347.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2348.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2349.                   break;
  2350.                 }
  2351.                 case 222:
  2352.                 {
  2353.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2354.                   if (Diff(w[2], w[6]))
  2355.                   {
  2356.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2357.                   }
  2358.                   else
  2359.                   {
  2360.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2361.                   }
  2362.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2363.                   if (Diff(w[6], w[8]))
  2364.                   {
  2365.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2366.                   }
  2367.                   else
  2368.                   {
  2369.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2370.                   }
  2371.                   break;
  2372.                 }
  2373.                 case 252:
  2374.                 {
  2375.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[2]);
  2376.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2377.                   if (Diff(w[8], w[4]))
  2378.                   {
  2379.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2380.                   }
  2381.                   else
  2382.                   {
  2383.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2384.                   }
  2385.                   if (Diff(w[6], w[8]))
  2386.                   {
  2387.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2388.                   }
  2389.                   else
  2390.                   {
  2391.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2392.                   }
  2393.                   break;
  2394.                 }
  2395.                 case 249:
  2396.                 {
  2397.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2398.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[2]);
  2399.                   if (Diff(w[8], w[4]))
  2400.                   {
  2401.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2402.                   }
  2403.                   else
  2404.                   {
  2405.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2406.                   }
  2407.                   if (Diff(w[6], w[8]))
  2408.                   {
  2409.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2410.                   }
  2411.                   else
  2412.                   {
  2413.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2414.                   }
  2415.                   break;
  2416.                 }
  2417.                 case 235:
  2418.                 {
  2419.                   if (Diff(w[4], w[2]))
  2420.                   {
  2421.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2422.                   }
  2423.                   else
  2424.                   {
  2425.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2426.                   }
  2427.                   out[outX+1+outY*Xres*2] = Interp2(c[5], c[3], c[6]);
  2428.                   if (Diff(w[8], w[4]))
  2429.                   {
  2430.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2431.                   }
  2432.                   else
  2433.                   {
  2434.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2435.                   }
  2436.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2437.                   break;
  2438.                 }
  2439.                 case 111:
  2440.                 {
  2441.                   if (Diff(w[4], w[2]))
  2442.                   {
  2443.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2444.                   }
  2445.                   else
  2446.                   {
  2447.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2448.                   }
  2449.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2450.                   if (Diff(w[8], w[4]))
  2451.                   {
  2452.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2453.                   }
  2454.                   else
  2455.                   {
  2456.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2457.                   }
  2458.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[6]);
  2459.                   break;
  2460.                 }
  2461.                 case 63:
  2462.                 {
  2463.                   if (Diff(w[4], w[2]))
  2464.                   {
  2465.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2466.                   }
  2467.                   else
  2468.                   {
  2469.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2470.                   }
  2471.                   if (Diff(w[2], w[6]))
  2472.                   {
  2473.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2474.                   }
  2475.                   else
  2476.                   {
  2477.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2478.                   }
  2479.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2480.                   out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[9], c[8]);
  2481.                   break;
  2482.                 }
  2483.                 case 159:
  2484.                 {
  2485.                   if (Diff(w[4], w[2]))
  2486.                   {
  2487.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2488.                   }
  2489.                   else
  2490.                   {
  2491.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2492.                   }
  2493.                   if (Diff(w[2], w[6]))
  2494.                   {
  2495.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2496.                   }
  2497.                   else
  2498.                   {
  2499.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2500.                   }
  2501.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[8]);
  2502.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2503.                   break;
  2504.                 }
  2505.                 case 215:
  2506.                 {
  2507.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2508.                   if (Diff(w[2], w[6]))
  2509.                   {
  2510.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2511.                   }
  2512.                   else
  2513.                   {
  2514.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2515.                   }
  2516.                   out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[7], c[4]);
  2517.                   if (Diff(w[6], w[8]))
  2518.                   {
  2519.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2520.                   }
  2521.                   else
  2522.                   {
  2523.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2524.                   }
  2525.                   break;
  2526.                 }
  2527.                 case 246:
  2528.                 {
  2529.                   out[outX+outY*Xres*2] = Interp2(c[5], c[1], c[4]);
  2530.                   if (Diff(w[2], w[6]))
  2531.                   {
  2532.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2533.                   }
  2534.                   else
  2535.                   {
  2536.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2537.                   }
  2538.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2539.                   if (Diff(w[6], w[8]))
  2540.                   {
  2541.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2542.                   }
  2543.                   else
  2544.                   {
  2545.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2546.                   }
  2547.                   break;
  2548.                 }
  2549.                 case 254:
  2550.                 {
  2551.                   out[outX+outY*Xres*2] = Interp1(c[5], c[1]);
  2552.                   if (Diff(w[2], w[6]))
  2553.                   {
  2554.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2555.                   }
  2556.                   else
  2557.                   {
  2558.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2559.                   }
  2560.                   if (Diff(w[8], w[4]))
  2561.                   {
  2562.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2563.                   }
  2564.                   else
  2565.                   {
  2566.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2567.                   }
  2568.                   if (Diff(w[6], w[8]))
  2569.                   {
  2570.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2571.                   }
  2572.                   else
  2573.                   {
  2574.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2575.                   }
  2576.                   break;
  2577.                 }
  2578.                 case 253:
  2579.                 {
  2580.                   out[outX+outY*Xres*2] = Interp1(c[5], c[2]);
  2581.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[2]);
  2582.                   if (Diff(w[8], w[4]))
  2583.                   {
  2584.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2585.                   }
  2586.                   else
  2587.                   {
  2588.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2589.                   }
  2590.                   if (Diff(w[6], w[8]))
  2591.                   {
  2592.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2593.                   }
  2594.                   else
  2595.                   {
  2596.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2597.                   }
  2598.                   break;
  2599.                 }
  2600.                 case 251:
  2601.                 {
  2602.                   if (Diff(w[4], w[2]))
  2603.                   {
  2604.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2605.                   }
  2606.                   else
  2607.                   {
  2608.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2609.                   }
  2610.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[3]);
  2611.                   if (Diff(w[8], w[4]))
  2612.                   {
  2613.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2614.                   }
  2615.                   else
  2616.                   {
  2617.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2618.                   }
  2619.                   if (Diff(w[6], w[8]))
  2620.                   {
  2621.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2622.                   }
  2623.                   else
  2624.                   {
  2625.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2626.                   }
  2627.                   break;
  2628.                 }
  2629.                 case 239:
  2630.                 {
  2631.                   if (Diff(w[4], w[2]))
  2632.                   {
  2633.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2634.                   }
  2635.                   else
  2636.                   {
  2637.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2638.                   }
  2639.                   out[outX+1+outY*Xres*2] = Interp1(c[5], c[6]);
  2640.                   if (Diff(w[8], w[4]))
  2641.                   {
  2642.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2643.                   }
  2644.                   else
  2645.                   {
  2646.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2647.                   }
  2648.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[6]);
  2649.                   break;
  2650.                 }
  2651.                 case 127:
  2652.                 {
  2653.                   if (Diff(w[4], w[2]))
  2654.                   {
  2655.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2656.                   }
  2657.                   else
  2658.                   {
  2659.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2660.                   }
  2661.                   if (Diff(w[2], w[6]))
  2662.                   {
  2663.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2664.                   }
  2665.                   else
  2666.                   {
  2667.                     out[outX+1+outY*Xres*2] = Interp2(c[5], c[2], c[6]);
  2668.                   }
  2669.                   if (Diff(w[8], w[4]))
  2670.                   {
  2671.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2672.                   }
  2673.                   else
  2674.                   {
  2675.                     out[outX + (outY+1)*Xres*2] = Interp2(c[5], c[8], c[4]);
  2676.                   }
  2677.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[9]);
  2678.                   break;
  2679.                 }
  2680.                 case 191:
  2681.                 {
  2682.                   if (Diff(w[4], w[2]))
  2683.                   {
  2684.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2685.                   }
  2686.                   else
  2687.                   {
  2688.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2689.                   }
  2690.                   if (Diff(w[2], w[6]))
  2691.                   {
  2692.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2693.                   }
  2694.                   else
  2695.                   {
  2696.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2697.                   }
  2698.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2699.                   out[outX+1 + (outY+1)*Xres*2] = Interp1(c[5], c[8]);
  2700.                   break;
  2701.                 }
  2702.                 case 223:
  2703.                 {
  2704.                   if (Diff(w[4], w[2]))
  2705.                   {
  2706.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2707.                   }
  2708.                   else
  2709.                   {
  2710.                     out[outX+outY*Xres*2] = Interp2(c[5], c[4], c[2]);
  2711.                   }
  2712.                   if (Diff(w[2], w[6]))
  2713.                   {
  2714.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2715.                   }
  2716.                   else
  2717.                   {
  2718.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2719.                   }
  2720.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[7]);
  2721.                   if (Diff(w[6], w[8]))
  2722.                   {
  2723.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2724.                   }
  2725.                   else
  2726.                   {
  2727.                     out[outX+1 + (outY+1)*Xres*2] = Interp2(c[5], c[6], c[8]);
  2728.                   }
  2729.                   break;
  2730.                 }
  2731.                 case 247:
  2732.                 {
  2733.                   out[outX+outY*Xres*2] = Interp1(c[5], c[4]);
  2734.                   if (Diff(w[2], w[6]))
  2735.                   {
  2736.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2737.                   }
  2738.                   else
  2739.                   {
  2740.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2741.                   }
  2742.                   out[outX + (outY+1)*Xres*2] = Interp1(c[5], c[4]);
  2743.                   if (Diff(w[6], w[8]))
  2744.                   {
  2745.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2746.                   }
  2747.                   else
  2748.                   {
  2749.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2750.                   }
  2751.                   break;
  2752.                 }
  2753.                 case 255:
  2754.                 {
  2755.                   if (Diff(w[4], w[2]))
  2756.                   {
  2757.                     out[outX+outY*Xres*2] = c[5]|0xFF000000;
  2758.                   }
  2759.                   else
  2760.                   {
  2761.                     out[outX+outY*Xres*2] = Interp10(c[5], c[4], c[2]);
  2762.                   }
  2763.                   if (Diff(w[2], w[6]))
  2764.                   {
  2765.                     out[outX+1+outY*Xres*2] = c[5]|0xFF000000;
  2766.                   }
  2767.                   else
  2768.                   {
  2769.                     out[outX+1+outY*Xres*2] = Interp10(c[5], c[2], c[6]);
  2770.                   }
  2771.                   if (Diff(w[8], w[4]))
  2772.                   {
  2773.                     out[outX + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2774.                   }
  2775.                   else
  2776.                   {
  2777.                     out[outX + (outY+1)*Xres*2] = Interp10(c[5], c[8], c[4]);
  2778.                   }
  2779.                   if (Diff(w[6], w[8]))
  2780.                   {
  2781.                     out[outX+1 + (outY+1)*Xres*2] = c[5]|0xFF000000;
  2782.                   }
  2783.                   else
  2784.                   {
  2785.                     out[outX+1 + (outY+1)*Xres*2] = Interp10(c[5], c[6], c[8]);
  2786.                   }
  2787.                   break;
  2788.                 }
  2789.               }
  2790.               outX+=2;
  2791.             }
  2792.             outY+=2;
  2793.           }
  2794.         }
  2795.  
  2796.              
  2797.         private static void InitLUTs()
  2798.         {
  2799.                 int i, j, k, r, g, b, Y, u, v;
  2800.  
  2801.                 for (i=0; i<65536; i++){
  2802.                         LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
  2803.                 }
  2804.                
  2805.             for (i=0; i<32; i++)
  2806.             for (j=0; j<64; j++)
  2807.             for (k=0; k<32; k++) {
  2808.                         r = i << 3;
  2809.                         g = j << 2;
  2810.                         b = k << 3;
  2811.                         Y = (r + g + b) >> 2;
  2812.                         u = 128 + ((r - b) >> 2);
  2813.                         v = 128 + ((-r + 2*g -b)>>3);
  2814.                         RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
  2815.             }
  2816.             lutsOk = true;
  2817.         }
  2818.        
  2819.         private static int RGB8888toRGB565(int rgb){
  2820.                 return ((rgb & 0x00F80000) >> 8) | ((rgb & 0x0000FC00) >> 5) | ((rgb & 0x000000F8) >> 3);  
  2821.         }
  2822.        
  2823.  
  2824.         private static BufferedImage addAlpha (BufferedImage image){
  2825.             final int width = image.getWidth();
  2826.             int[] imgData = new int[width];
  2827.            
  2828.             for (int y = 0; y < image.getHeight(); y++) {
  2829.                 // fetch a line of data from each image
  2830.                 image.getRGB(0, y, width, 1, imgData, 0, 1);
  2831.                 // apply the mask
  2832.                 for (int x = 0; x < width; x++) {
  2833.                     int color = imgData[x] & 0x00FFFFFF; // mask away any alpha present
  2834.                     int alpha = (imgData[x] & 0xFF000000) << 8; // shift red into alpha bits
  2835.                     color |= alpha;
  2836.                     imgData[x] = color;
  2837.                 }
  2838.                 // replace the data
  2839.                 image.setRGB(0, y, width, 1, imgData, 0, 1);
  2840.             }
  2841.             return image;
  2842.         }
  2843.        
  2844.         private static BufferedImage removeAlpha (BufferedImage image){
  2845.             final int width = image.getWidth();
  2846.             int[] imgData = new int[width];
  2847.            
  2848.             for (int y = 0; y < image.getHeight(); y++) {
  2849.                 // fetch a line of data from each image
  2850.                 image.getRGB(0, y, width, 1, imgData, 0, 1);
  2851.                 // apply the mask
  2852.                 for (int x = 0; x < width; x++) {
  2853.                     int color = imgData[x] & 0x00FFFFFF; // mask away any alpha present
  2854.                     int alpha = (imgData[x] & 0x00FF0000) << 8; // shift red into alpha bits
  2855.                     color |= alpha;
  2856.                     imgData[x] = color;
  2857.                 }
  2858.                 // replace the data
  2859.                 image.setRGB(0, y, width, 1, imgData, 0, 1);
  2860.             }
  2861.             return image;
  2862.         }
  2863.  
  2864.         public BufferedImage HQ2X(BufferedImage in){
  2865.  
  2866.             in = removeAlpha(in);
  2867.  
  2868.             int w = in.getWidth();
  2869.             int h = in.getHeight();
  2870.             BufferedImage out = new BufferedImage(w*2, h*2, BufferedImage.TYPE_INT_ARGB);
  2871.             int x = out.getWidth();
  2872.             int y = out.getHeight();
  2873.             int[] inArr  = new int[w*h];
  2874.             int[] outArr = new int[w*h*4];
  2875.  
  2876.             in.getRGB(0, 0, w, h, inArr, 0, w);
  2877.  
  2878.             if (!lutsOk)
  2879.             {
  2880.                 LUT16to32 = new int[65536];
  2881.                 RGBtoYUV  = new int[65536];
  2882.                 InitLUTs();
  2883.             }
  2884.  
  2885.             hq2x_32(inArr, outArr, w, h);
  2886.             out.setRGB(0, 0, x, y, outArr, 0, x);
  2887.  
  2888.             out = addAlpha(out);
  2889.  
  2890.             return out;
  2891.         }
  2892. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment