Progressive JPG image
Can anybody help me creating progressive jpeg images?
I believed this was done using:
System.Drawing.Imaging.Encoder.ScanMethod
but its not working.
Did not find anything in MSDN and in google.
Here is the code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
' create Image object from posted image file
Dim imgObj As System.Drawing.Image
imgObj = System.Drawing.Image.FromStream(upFile.PostedFile. InputStream)
' create bitmap object with required dimensions
Dim bmpObj As Bitmap
Dim ImageWidth As Integer = 800, ImageHeight As Integer = 600
bmpObj = New Bitmap(imgObj, ImageWidth, ImageHeight)
' select JPEG codec
Dim CodecInfo() As System.Drawing.Imaging.ImageCodecInfo
Dim JpgCodec As System.Drawing.Imaging.ImageCodecInfo
CodecInfo = System.Drawing.Imaging.ImageCodecInfo.GetImageEnco ders()
JpgCodec = CodecInfo(1)
' add parameters to the codec
' the ScanMethod parameter is not working, maybe the inbuilt codec does not support it.
Dim ParametersCount As Integer = 2
Dim EncParams As New System.Drawing.Imaging.EncoderParameters(Parameter sCount)
Dim JpgQuality As Integer = 50
Dim ScanMethod As Integer = 2
EncParams.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Dra wing.Imaging.Encoder.Quality, JpgQuality)
EncParams.Param(1) = New System.Drawing.Imaging.EncoderParameter (System.Drawing.Imaging.Encoder.ScanMethod, ScanMethod)
' save the file
Dim FullFilePath As String = "g:\tmp\aa.jpg"
bmpObj.Save(FullFilePath, JpgCodec, EncParams)
End If
End Sub
|