Example #1
0
        /// <summary>
        /// Gets a readonly stream from the given bitmap.
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns></returns>
        public static IStream GetReadOnlyStream(this Bitmap bitmap)
        {
            ReadOnlyStream stream = null;

            try
            {
                var memory = new MemoryStream();
                bitmap.Save(memory, ImageFormat.Png);
                stream = new ReadOnlyStream(memory);
            }
            catch (Exception exc)
            {
                Logger.Current.WriteLine(exc);
            }

            return(stream);
        }
Example #2
0
        //========================================================================================
        // IStream implementation
        //========================================================================================

        /// <summary>
        /// Creates a new stream object with its own seek pointer that references the
        /// same bytes as the original stream.
        /// </summary>
        /// <param name="ppstm">
        /// Upon return, contains the new stream object.
        /// </param>

        public void Clone(out IStream ppstm)
        {
            ppstm = new ReadOnlyStream(stream);
        }