Пример #1
0
 static unsafe ByteUtil()
 {
     for (int i = 0; i <= 0xff; i++)
     {
         for (int n = 0; n <= 0xff; n++)
         {
             int index = i + (n * 0x100);
             if (n == 0)
             {
                 pUnscaleLookup[index] = 0;
             }
             else
             {
                 pUnscaleLookup[index] = Int32Util.ClampToByte((i * 0xff) / n);
             }
         }
     }
     pByteToScalingFloatLookup  = (float *)Marshal.AllocCoTaskMem(0x400);
     pByteToScalingDoubleLookup = (double *)Marshal.AllocCoTaskMem(0x800);
     for (int j = 0; j <= 0xff; j++)
     {
         pByteToScalingFloatLookup[j * 4]  = ((float)j) / 255f;
         pByteToScalingDoubleLookup[j * 8] = ((double)j) / 255.0;
     }
     pHighestBitLookup = (byte *)Marshal.AllocCoTaskMem(0x100);
     for (int k = 2; k < 7; k++)
     {
         int num6 = (k << 2) - 1;
         for (int num7 = num6; num7 < (num6 + k); num7++)
         {
             pHighestBitLookup[num7] = (byte)k;
         }
     }
     pFastScaleLookup = (byte *)Marshal.AllocCoTaskMem(0x10000);
     for (int m = 0; m <= 0xff; m++)
     {
         for (int num9 = 0; num9 <= 0xff; num9++)
         {
             pFastScaleLookup[(num9 << 8) + m] = FastScaleImpl((byte)m, (byte)num9);
         }
     }
 }
Пример #2
0
 public static int Clamp(this int value, int min, int max) =>
 Int32Util.Clamp(value, min, max);
Пример #3
0
 public object BoxValue(int value) =>
 Int32Util.GetBoxed(value);
Пример #4
0
 public static object GetInt32(int value) =>
 Int32Util.GetBoxed(value);