GenuineSounds

[Java] HQ2X Filter

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