コード例 #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);
     InitializeFromIStream(streamProxy);
 }
コード例 #2
0
ファイル: IWICStream.cs プロジェクト: plynkus/Vortice.Windows
 private void DisposeStreamProxy()
 {
     if (_streamProxy != null)
     {
         _streamProxy.Dispose();
         _streamProxy = null;
     }
 }
コード例 #3
0
ファイル: IWICStream.cs プロジェクト: plynkus/Vortice.Windows
        public void Initialize(Stream stream)
        {
            Guard.NotNull(stream, nameof(stream));

            DisposeStreamProxy();
            _streamProxy = new ComStreamProxy(stream);
            InitializeFromIStream(_streamProxy);
        }
コード例 #4
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);
        }
コード例 #5
0
        protected override void Dispose(bool disposing)
        {
            if (streamProxy != null)
            {
                streamProxy.Dispose();
                streamProxy = null;
            }

            base.Dispose(disposing);
        }
コード例 #6
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 STORE_APP
            var randomAccessStream = sourceStream.AsRandomAccessStream();
            MediaFactory.CreateMFByteStreamOnStreamEx(new ComObject(Marshal.GetIUnknownForObject(randomAccessStream)), this);
#else
            streamProxy = new ComStreamProxy(sourceStream);
            MediaFactory.CreateMFByteStreamOnStream(streamProxy, this);
#endif
        }
コード例 #7
0
ファイル: ByteStream.cs プロジェクト: superowner/AudioSharp
        /// <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>
        protected ByteStream(Stream sourceStream)
        {
            this.sourceStream = sourceStream;
#if STORE_APP
            var randomAccessStream = sourceStream.AsRandomAccessStream();
            randomAccessStreamCom = new ComObject(Marshal.GetIUnknownForObject(randomAccessStream));
            MediaFactory.CreateMFByteStreamOnStreamEx(randomAccessStreamCom, this);
#else
            streamProxy = new ComStreamProxy(sourceStream);
            MediaFactory.CreateMFByteStreamOnStream(ComStream.ToIntPtr(streamProxy), this);
#endif
        }
コード例 #8
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
        }
コード例 #9
0
        protected override unsafe void Dispose(bool disposing)
        {
            base.Dispose(disposing);

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

            if (randomAccessStreamCom != null)
            {
                randomAccessStreamCom.Dispose();
                randomAccessStreamCom = null;
            }
        }
コード例 #10
0
 /// <summary>
 /// Initialize the <see cref="IWICStream"/> from another stream. Access rights are inherited from the underlying stream
 /// </summary>
 /// <param name="stream">The initialize stream.</param>
 public void Initialize(Stream stream)
 {
     DisposeStreamProxy();
     _streamProxy = new ComStreamProxy(stream);
     InitializeFromIStream(_streamProxy);
 }