Exemplo n.º 1
0
        public byte[] EncodeGdi(SD.Bitmap image, float bitrate = WsqCodec.Constants.DefaultBitrate, bool autoConvertToGrayscale = true)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            RawImageData data = null;

            if (autoConvertToGrayscale)
            {
                using (var source = Conversions.To8bppBitmap(image))
                    data = Conversions.GdiImageToImageInfo(source);
            }
            else
            {
                data = Conversions.GdiImageToImageInfo(image);
            }

            return(WsqCodec.Encode(data, bitrate, Comment));
        }
Exemplo n.º 2
0
        public byte[] EncodeWpf(SWMI.BitmapSource image, float bitrate = WsqCodec.Constants.DefaultBitrate, bool autoConvertToGrayscale = true)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            SWMI.BitmapSource source = null;
            if (autoConvertToGrayscale)
            {
                source = Conversions.ToGray8BitmapSource(image);
            }
            else
            {
                source = image;
            }

            var data = Conversions.WpfImageToImageInfo(source);

            return(WsqCodec.Encode(data, bitrate, Comment));
        }
Exemplo n.º 3
0
 public byte[] Encode(RawImageData image, float bitrate = WsqCodec.Constants.DefaultBitrate)
 {
     return(WsqCodec.Encode(image, bitrate, Comment));
 }