示例#1
0
 public void Save_UnknownExtensionsEncoding()
 {
     string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.tmp");
     NotSupportedException ex = Assert.Throws <NotSupportedException>(
         () =>
     {
         using (Image <Rgba32> image = new Image <Rgba32>(10, 10))
         {
             image.Save(file);
         }
     });
 }
示例#2
0
 public void Save_UnknownExtensionsEncoding()
 {
     string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.tmp");
     var    ex   = Assert.Throws <InvalidOperationException>(
         () =>
     {
         using (Image image = new Image(10, 10))
         {
             image.Save(file);
         }
     });
 }
示例#3
0
        public void Save_SetEncoding()
        {
            string file = TestFile.GetPath("../../TestOutput/Save_SetEncoding.dat");

            System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
            using (Image <Rgba32> image = new Image <Rgba32>(10, 10))
            {
                image.Save(file, new PngEncoder());
            }
            using (Image <Rgba32> img = Image.Load(file, out var mime))
            {
                Assert.Equal("image/png", mime.DefaultMimeType);
            }
        }
示例#4
0
        public void Benchmark_JpegDecoder(string fileName)
        {
            string path = TestFile.GetPath(fileName);

            byte[] bytes = File.ReadAllBytes(path);

            this.Measure(
                100,
                () =>
            {
                Image img = new Image(bytes);
            },
                $"Decode {fileName}");
        }
示例#5
0
        public void Save_DetecedEncoding()
        {
            string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.png");
            var    dir  = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));

            using (Image image = new Image(10, 10))
            {
                image.Save(file);
            }

            var c = TestFile.Create("../../TestOutput/Save_DetecedEncoding.png");

            using (var img = c.CreateImage())
            {
                Assert.IsType <PngFormat>(img.CurrentImageFormat);
            }
        }
示例#6
0
        public void Save_SetEncoding()
        {
            string file = TestFile.GetPath("../../TestOutput/Save_SetEncoding.dat");

            System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
            using (Image image = new Image(10, 10))
            {
                image.Save(file, new PngEncoder());
            }

            TestFile c = TestFile.Create("../../TestOutput/Save_SetEncoding.dat");

            using (Image img = c.CreateImage())
            {
                Assert.IsType <PngFormat>(img.CurrentImageFormat);
            }
        }
        public void DecodeJpeg(string fileName)
        {
            const int ExecutionCount = 30;

            if (!Vector.IsHardwareAccelerated)
            {
                throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)");
            }

            string path = TestFile.GetPath(fileName);

            byte[] bytes = File.ReadAllBytes(path);

            this.Measure(
                ExecutionCount,
                () =>
            {
                Image img = Image.Load(bytes);
            },
                // ReSharper disable once ExplicitCallerInfoArgument
                $"Decode {fileName}");
        }