public void LoadImage(string filePath)
        {
            TestContext.CurrentContext.AttachFolderBrowserShortcut();

            var codecs = new IBitmapDecoder[] { OpenCvCodec.Default, GDICodec.Default, WPFCodec.Default, ImageSharpCodec.Default, STBCodec.Default, SkiaCodec.Default };

            foreach (var decoder in codecs.OfType <IBitmapDecoder>())
            {
                var sw     = System.Diagnostics.Stopwatch.StartNew();
                var bitmap = MemoryBitmap.Load(ResourceInfo.From(filePath), decoder);
                sw.Stop();

                TestContext.WriteLine($"Loading {System.IO.Path.GetFileName(filePath)} with {decoder} tool {sw.ElapsedMilliseconds}");

                foreach (var encoder in codecs.OfType <IBitmapEncoder>())
                {
                    // System.Diagnostics.Debug.Assert(!(decoder is WPFCodec && encoder is SkiaCodec));

                    var fname = $"{decoder.GetType().Name}-To-{encoder.GetType().Name}.png";
                    bitmap.Save(new AttachmentInfo(fname), encoder);

                    fname = $"{decoder.GetType().Name}-To-{encoder.GetType().Name}.jpg";
                    bitmap.Save(new AttachmentInfo(fname), encoder);

                    fname = $"{decoder.GetType().Name}-To-{encoder.GetType().Name}-Gray.jpg";
                    bitmap
                    .AsSpanBitmap()
                    .ToMemoryBitmap(Pixel.Luminance8.Format)
                    .Save(AttachmentInfo.From(fname), encoder);
                }
            }
        }
Beispiel #2
0
 public static IBitmapDecoder CreateRef(this IBitmapDecoder objectRef) =>
 ((IBitmapDecoder)objectRef.CreateRef(typeof(IBitmapDecoder)));
Beispiel #3
0
 public BitmapFrameList(IBitmapDecoder decoder)
 {
     _decoder = decoder;
 }
Beispiel #4
0
 public PlatformBitmapDecoder(Stream source)
 {
     _decoder = MediaResourceManager.Current.CreateBitmapDecoderFromStream(source);
     Frames   = new BitmapFrameList(_decoder);
 }