<Extension()> _ Public Sub Save(ByVal b As Bitmap,ByVal FileName As String,ByVal Compression As Long,ByVal MimeType As String) Dim Params As EncoderParameters = New EncoderParameters(2) Dim CodecInfo As ImageCodecInfo = GetEncoderInfo(MimeType) Params.Param(0) = New EncoderParameter(Encoder.RenderMethod,EncoderValue.RenderProgressive) Params.Param(1) = New EncoderParameter(Encoder.Quality,Compression) b.Save(FileName,CodecInfo,Params) End Sub
这不起作用.它没有被保存为渐进式.我怎么能这样做,也可以指定通行证的数量.
解决方法
据我所知,它不受支持.我尝试过建议
here和
here的代码,并得到了这个C#代码:
using (Image source = Image.FromFile(@"D:\temp\test2.jpg")) { ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders().First(c => c.MimeType == "image/jpeg"); EncoderParameters parameters = new EncoderParameters(3); parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality,100L); parameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod,(int)EncoderValue.ScanMethodInterlaced); parameters.Param[2] = new EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod,(int)EncoderValue.RenderProgressive); source.Save(@"D:\temp\saved.jpg",codec,parameters); }
设置隔行和逐行模式,它仍然保存常规基线JPEG.我尝试了任何设置和其他设置(非隔行扫描和非渐进式)的任意组合,并且在生成的图像文件中根本没有看到任何差异.
我没有发现任何人说他们实际上已经设法在.NET中保存渐进式JPEG的任何回复.
ScanMethodInterlaced和RenderProgressive参数值仅描述为“未在GDI版本1.0中使用”.在 the documentation.