Exemplo n.º 1
0
        public void  DimensionsCorrect()
        {
            int width    = 64;
            int channels = 3;
            int bitDepth = 8;

            TextureData1D data = TextureData1D.CreateData(width, channels, bitDepth);

            Assert.AreEqual(width, data.GetWidth());
            Assert.AreEqual(channels, data.Channels);
        }
Exemplo n.º 2
0
 void EqualsWithError(float[,] arr, TextureData1D data, float error)
 {
     for (int x = 0; x < data.GetWidth(); x++)
     {
         for (int c = 0; c < data.Channels; c++)
         {
             float diff = Math.Abs(arr[x, c] - data[x, c]);
             Assert.IsTrue(diff <= error, arr[x, c] + " and " + data[x, c] + " have a error of " + diff);
         }
     }
 }
Exemplo n.º 3
0
        public void  DataTypeCorrect()
        {
            int           width    = 512;
            int           channels = 3;
            TextureData1D data     = null;

            data = TextureData1D.CreateData(width, channels, 8);
            Assert.IsInstanceOfType(data, typeof(TextureData1D8));

            data = TextureData1D.CreateData(width, channels, 16);
            Assert.IsInstanceOfType(data, typeof(TextureData1D16));

            data = TextureData1D.CreateData(width, channels, 32);
            Assert.IsInstanceOfType(data, typeof(TextureData1D32));
        }
Exemplo n.º 4
0
        public void Index32()
        {
            int width    = 64;
            int channels = 3;
            int bitDepth = 32;

            TextureData1D data = TextureData1D.CreateData(width, channels, bitDepth);

            float[,] arr = new float[width, channels];

            Random rnd = new Random(0);

            for (int x = 0; x < data.GetWidth(); x++)
            {
                for (int c = 0; c < data.Channels; c++)
                {
                    arr[x, c]  = (float)rnd.NextDouble();
                    data[x, c] = arr[x, c];
                }
            }

            EqualsWithError(arr, data, 0);
        }
Exemplo n.º 5
0
        public void Index16()
        {
            int width    = 64;
            int channels = 3;
            int bitDepth = 16;

            TextureData1D data = TextureData1D.CreateData(width, channels, bitDepth);

            float[,] arr = new float[width, channels];

            Random rnd = new Random(0);

            for (int x = 0; x < data.GetWidth(); x++)
            {
                for (int c = 0; c < data.Channels; c++)
                {
                    short v = (short)rnd.Next(short.MinValue, short.MaxValue);
                    arr[x, c]  = v / (float)short.MaxValue;
                    data[x, c] = arr[x, c];
                }
            }

            EqualsWithError(arr, data, 1e-4f);
        }
Exemplo n.º 6
0
 private void CreateData(int width, int channels, int bitDepth)
 {
     Data = null;
     Data = TextureData1D.CreateData(width, channels, bitDepth);
 }