Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WICStream"/> class from a <see cref="IStream"/>.
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <param name="stream">The stream.</param>
 /// <msdn-id>ee719789</msdn-id>	
 /// <unmanaged>HRESULT IWICStream::InitializeFromIStream([In, Optional] IStream* pIStream)</unmanaged>	
 /// <unmanaged-short>IWICStream::InitializeFromIStream</unmanaged-short>	
 public WICStream(ImagingFactory factory, Stream stream)
     : base(IntPtr.Zero)
 {
     factory.CreateStream(this);
     streamProxy = new ComStreamProxy(stream);
     var istreamPtr = ComStreamShadow.ToIntPtr(streamProxy);
     InitializeFromIStream_(istreamPtr);
 }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            if (streamProxy != null)
            {
                streamProxy.Dispose();
                streamProxy = null;
            }

            base.Dispose(disposing);
        }
Example #3
0
 /// <summary>
 /// Instantiates a new instance <see cref="ByteStream"/> from a <see cref="Stream"/>.
 /// </summary>
 /// <msdn-id>hh162754</msdn-id>	
 /// <unmanaged>HRESULT MFCreateMFByteStreamOnStreamEx([In] IUnknown* punkStream,[Out] IMFByteStream** ppByteStream)</unmanaged>	
 /// <unmanaged-short>MFCreateMFByteStreamOnStreamEx</unmanaged-short>	
 public ByteStream(Stream sourceStream)
 {
     this.sourceStream = sourceStream;
     #if WIN8METRO
     var randomAccessStream = sourceStream.AsRandomAccessStream();
     randomAccessStreamCom = new ComObject(Marshal.GetIUnknownForObject(randomAccessStream));
     MediaFactory.CreateMFByteStreamOnStreamEx(randomAccessStreamCom, this);
     #else
     streamProxy = new ComStreamProxy(sourceStream);
     IByteStream localStream;
     MediaFactory.CreateMFByteStreamOnStream(ComStream.ToIntPtr(streamProxy), out localStream);
     NativePointer = ((ByteStream) localStream).NativePointer;
     #endif
 }
Example #4
0
        protected unsafe override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (streamProxy != null)
            {
                streamProxy.Dispose();
                streamProxy = null;
            }

            if (randomAccessStreamCom != null)
            {
                randomAccessStreamCom.Dispose();
                randomAccessStreamCom = null;
            }
        }