Esempio n. 1
0
        /// <summary>
        ///     Converts a bitmap source into a PNG byte array.
        /// </summary>
        /// <param name="image"> The bitmap source. </param>
        /// <param name="interlace"> The PNG interlace options. </param>
        /// <returns>
        ///     The byte array.
        /// </returns>
        /// <exception cref="ArgumentNullException"> <paramref name="image" /> is null. </exception>
        public static byte[] ToPngByteArray(this BitmapSource image, PngInterlaceOption interlace)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            PngBitmapEncoder encoder = new PngBitmapEncoder();

            encoder.Interlace = interlace;

            return(image.ToByteArray(encoder));
        }
Esempio n. 2
0
		/// <summary>Creates a converted copy of the image (png formatted).</summary>
		public static byte[] ConvertTo_PngByteArray(this BitmapSource input, PngInterlaceOption interlace = PngInterlaceOption.Default)
		{
			var encoder = new PngBitmapEncoder {Interlace = interlace, };
			return input.ConvertTo_UsingEncoder(encoder);
		}
Esempio n. 3
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="interlace">Whether to enable interlace mode.</param>
 public PngEncoder(bool interlace = false)
 {
     _interlace = interlace ? PngInterlaceOption.On : PngInterlaceOption.Off;
 }
Esempio n. 4
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="interlace">Whether to enable interlace mode.</param>
 public PngEncoder(bool interlace = false)
 {
     _interlace = interlace ? PngInterlaceOption.On : PngInterlaceOption.Off;
 }