/// <summary>
    /// Create a <see cref="IWICStream"/> from given data.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="data">Data to initialize with.</param>
    /// <returns>New instance of <see cref="IWICStream"/> or throws exception.</returns>
    public IWICStream CreateStream <T>(T[] data) where T : unmanaged
    {
        IWICStream wicStream = CreateStream_();

        wicStream.Initialize(data).CheckError();
        return(wicStream);
    }
    /// <summary>
    /// Create a <see cref="IWICStream"/> from another stream. Access rights are inherited from the underlying stream
    /// </summary>
    /// <param name="stream">The initialize stream.</param>
    /// <returns>New instance of <see cref="IWICStream"/> or throws exception.</returns>
    public IWICStream CreateStream(Stream stream)
    {
        IWICStream wicStream = CreateStream_();

        wicStream.Initialize(stream).CheckError();
        return(wicStream);
    }
    /// <summary>
    /// Create a <see cref="IWICStream"/> from file name.
    /// </summary>
    /// <param name="fileName">The file name.</param>
    /// <param name="access">The <see cref="FileAccess"/> mode.</param>
    /// <returns>New instance of <see cref="IWICStream"/> or throws exception.</returns>
    public IWICStream CreateStream(string fileName, FileAccess access)
    {
        IWICStream stream = CreateStream_();

        stream.Initialize(fileName, access).CheckError();
        return(stream);
    }
    /// <summary>
    /// Create a <see cref="IWICStream"/> from another stream. Access rights are inherited from the underlying stream
    /// </summary>
    /// <param name="comStream">The initialize stream.</param>
    /// <returns>New instance of <see cref="IWICStream"/> or throws exception.</returns>
    public IWICStream CreateStream(IStream comStream)
    {
        IWICStream stream = CreateStream_();

        stream.Initialize(comStream).CheckError();
        return(stream);
    }
Example #5
0
        public static Size GetTextureDimensions(IWICImagingFactory factory, Stream stream)
        {
            IWICStream wicStream = factory.CreateStream();

            wicStream.Initialize(stream);

            using (IWICBitmapDecoder decoder = factory.CreateDecoderFromStream(wicStream, DecodeOptions.CacheOnDemand))
            {
                var frame = decoder.GetFrame(0);
                using (frame)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    return(frame.Size);
                }
            }
        }