/// <summary> /// Loads a bitmap using WIC. /// </summary> /// <param name="inStream">The stream from which to load the texture file.</param> public static WicBitmapSourceInternal LoadBitmapSource_D2D(Stream inStream) { inStream.EnsureNotNull(nameof(inStream)); inStream.EnsureReadable(nameof(inStream)); GraphicsCore.EnsureGraphicsSupportLoaded(); // Parameter changed to represent this article (important is the correct Direct2D format): // https://msdn.microsoft.com/en-us/library/windows/desktop/dd756686(v=vs.85).aspx var wicFactory = GraphicsCore.Current.FactoryWIC; var bitmapDecoder = wicFactory !.CreateDecoderFromStream( inStream, DecodeOptions.CacheOnLoad); var formatConverter = wicFactory.CreateFormatConverter(); formatConverter.Initialize( bitmapDecoder.GetFrame(0), DEFAULT_WIC_BITMAP_FORMAT_DIRECT_2D, BitmapDitherType.None, null, 0.0, BitmapPaletteType.MedianCut); return(new WicBitmapSourceInternal(bitmapDecoder, formatConverter)); }
/// <summary> /// Imports all objects from the given source. /// </summary> /// <param name="objSource">The source to load from.</param> /// <param name="importOptions">All options for import logic.</param> public async Task <IEnumerable <SceneObject> > ImportAsync(ResourceLink objSource, ImportOptions?importOptions) { GraphicsCore.EnsureGraphicsSupportLoaded(); var modelContainer = await GraphicsCore.Current.ImportersAndExporters ! .ImportAsync(objSource, importOptions); return(await this.ImportAsync(modelContainer)); }
/// <summary> /// Loads a bitmap using WIC. /// </summary> /// <param name="inStream">The stream from which to load the texture file.</param> public static WicBitmapSourceInternal LoadBitmapSource(Stream inStream) { inStream.EnsureNotNull(nameof(inStream)); inStream.EnsureReadable(nameof(inStream)); GraphicsCore.EnsureGraphicsSupportLoaded(); var wicFactory = GraphicsCore.Current.FactoryWIC; var bitmapDecoder = wicFactory !.CreateDecoderFromStream( inStream, DecodeOptions.CacheOnDemand); var formatConverter = wicFactory.CreateFormatConverter(); formatConverter.Initialize( bitmapDecoder.GetFrame(0), DEFAULT_WIC_BITMAP_FORMAT, BitmapDitherType.None, null, 0.0, BitmapPaletteType.Custom); return(new WicBitmapSourceInternal(bitmapDecoder, formatConverter)); }