views:

329

answers:

1
<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

this does not work. Its not saved as progressive. How can i do this, and maybe also specify the nr of passes.??

A: 

As far as I can tell, it's not supported. I have tried code suggested here and here and arrived at this C# code:

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);
}

Setting both interlaced and progressive mode, it still saves a regular baseline JPEG. I have tried any combination of either setting and their alternative settings (non-interlaced and non-progressive), and haven't seen any difference at all in the resulting image file.

I haven't found any response from anyone saying that they have actually managed to save a progressive JPEG in .NET.

Both the ScanMethodInterlaced and RenderProgressive parameter values are described only as "Not used in GDI+ version 1.0." in the documentation.

Guffa