Esempio n. 1
0
        public static bool SaveImageData(Stream stream, string extension, IImageByte sourceImage)
        {
            try
            {
                Image <Rgba32> image2        = ImageBufferToImage32(sourceImage);
                var            formatManager = new SixLabors.ImageSharp.Formats.ImageFormatManager();
                SixLabors.ImageSharp.Formats.IImageFormat imageFormat = null;
                switch (extension.ToLower())
                {
                case ".jpg":
                case ".jpeg":
                    imageFormat = SixLabors.ImageSharp.Formats.Jpeg.JpegFormat.Instance;
                    break;

                case ".png":
                    imageFormat = SixLabors.ImageSharp.Formats.Png.PngFormat.Instance;
                    break;

                case ".gif":
                    imageFormat = SixLabors.ImageSharp.Formats.Gif.GifFormat.Instance;
                    break;

                default:
                    throw new NotImplementedException();
                }
                image2.Save(stream, imageFormat);

                return(true);
            }
            catch { }

            return(false);
        }
Esempio n. 2
0
 public SharpImageInfo(SixLabors.ImageSharp.IImageInfo info, SixLabors.ImageSharp.Formats.IImageFormat format)
 {
     _info   = info;
     _format = ImageSharpUtility.CreateFormat(format);
 }
Esempio n. 3
0
 public SharpImage(Image image, SharpFormat sharpFormat)
     : this(image, ImageSharpUtility.CreateFormat(sharpFormat))
 {
 }