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); } } }
public static IBitmapDecoder CreateRef(this IBitmapDecoder objectRef) => ((IBitmapDecoder)objectRef.CreateRef(typeof(IBitmapDecoder)));
public BitmapFrameList(IBitmapDecoder decoder) { _decoder = decoder; }
public PlatformBitmapDecoder(Stream source) { _decoder = MediaResourceManager.Current.CreateBitmapDecoderFromStream(source); Frames = new BitmapFrameList(_decoder); }