示例#1
0
        public static byte[] ResizeImageTo(byte[] img, int w, int h, bool fromOutside)
        {
            SixLabors.ImageSharp.Image <Rgba32> bmp = null;
            try
            {
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(img))
                    bmp = SixLabors.ImageSharp.Image.Load(ms);

                using (var resultImg = ResizeImageTo(bmp, w, h, fromOutside))
                {
                    using (System.IO.MemoryStream outMS = new System.IO.MemoryStream())
                    {
                        resultImg.Save(outMS, new SixLabors.ImageSharp.Formats.Png.PngEncoder());
                        return(outMS.ToArray());
                    }
                }
            }
            finally
            {
                if (bmp != null)
                {
                    bmp.Dispose();
                }
            }
        }
 public void Dispose()
 {
     _image.Dispose();
 }