我有一张图片(以byte[]数组形式),我想获得一个压缩版本。可以是PNG或JPEG压缩版本。
我目前使用以下代码:
我目前使用以下代码:
private Media.ImageSource GetImage(byte[] imageData, System.Windows.Media.PixelFormat format, int width = 640, int height = 480)
{
return System.Windows.Media.Imaging.BitmapSource.Create(width, height, 96, 96, format, null, imageData, width * format.BitsPerPixel / 8);
}
如何扩展这个功能,以便可以压缩并返回图像源的压缩版本(质量降低)。
提前致谢!