public BblBitmapSource(MemoryStream stream) { try { using (var fac = new ImagingFactory()) { _pinnedArray = GCHandle.Alloc(stream.GetBuffer(), GCHandleType.Pinned); IntPtr pointer = _pinnedArray.AddrOfPinnedObject(); SharpDX.DataPointer p = new SharpDX.DataPointer(pointer, (int)stream.Length); using (WICStream wstream = new WICStream(fac, p)) { using (SharpDX.WIC.BitmapDecoder dec = new SharpDX.WIC.BitmapDecoder(fac, wstream, Guid.Empty, DecodeOptions.CacheOnDemand)) { WICBitmapSource = dec.GetFrame(0); } } } } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="DataBuffer"/> class. /// </summary> /// <param name="dataPointer">The data pointer.</param> public DataBuffer(DataPointer dataPointer) : this(dataPointer.Pointer, dataPointer.Size) { }
/// <summary> /// Initializes a new instance of the <see cref="DataStream"/> class. /// </summary> /// <param name="dataPointer">The data pointer.</param> public DataStream(DataPointer dataPointer) : this(dataPointer.Pointer, dataPointer.Size, true, true) { }