Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(WPF C#)图像水印和调整大小_C#_Wpf_Image_Watermark - Fatal编程技术网

(WPF C#)图像水印和调整大小

(WPF C#)图像水印和调整大小,c#,wpf,image,watermark,C#,Wpf,Image,Watermark,我的WPF应用程序已经可以进行图像大小调整和文本水印。当转换的图像大小为700px 700px,水印文本为30磅时,我的应用程序将4MB图像转换为600KB图像 如何减小图像大小(600 KB到250 KB或更小) 考虑到我的应用程序是使用WPF、C#和.NET 4编写的,我应该使用哪个库或代码示例?减少图像大小有两种方法:降低分辨率或使用所用格式的压缩参数(即,jpeg压缩基于余弦变换,可以控制质量(和大小)最后一张图片) 我使用BitmapSource扩展方法来控制我保存的Jpeg图像的质量

我的WPF应用程序已经可以进行图像大小调整和文本水印。当转换的图像大小为700px 700px,水印文本为30磅时,我的应用程序将4MB图像转换为600KB图像

如何减小图像大小(600 KB到250 KB或更小)


考虑到我的应用程序是使用WPF、C#和.NET 4编写的,我应该使用哪个库或代码示例?

减少图像大小有两种方法:降低分辨率或使用所用格式的压缩参数(即,jpeg压缩基于余弦变换,可以控制质量(和大小)最后一张图片)

我使用BitmapSource扩展方法来控制我保存的Jpeg图像的质量。也许你会发现它很有用:

    public static void SaveBitmapSourceAsJpeg(this BitmapSource image, string fileName, int quality)
    {
        using (var fileStream = new FileStream(fileName, FileMode.Create))
        {
            var encoder = new JpegBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(image));
            encoder.QualityLevel = quality;
            encoder.Save(fileStream);
        }
    }