【发布时间】:2011-04-26 16:10:09
【问题描述】:
当我使用 bitmap.save 保存 jpg 文件时,当我指定编码器和质量时它保存为 jpeg 4-1-1,但当我不指定时保存为 4-2-2。我想将其保存为 4-2-2,其质量比默认值更高。使用 bitmap.save 可以吗?用 4-1-1 保存会失去什么吗?
Dim bmp As Bitmap
Dim ep As New EncoderParameters(1)
Dim sysCodecs() As ImageCodecInfo
Dim jpgCodec, cdc As ImageCodecInfo
sysCodecs = ImageCodecInfo.GetImageEncoders()
' get jpg codec
jpgCodec = Nothing
For Each cdc In sysCodecs
If String.Compare(cdc.MimeType, "image/jpeg", True) = 0 Then
jpgCodec = cdc
Exit For
End If
Next cdc
If jpgCodec IsNot Nothing Then
ep.Param(0) = New EncoderParameter(Encoder.Quality, 97)
bmp = Bitmap.FromFile(filename)
bmp.Save(outname, jpgCodec, ep) ' saves 4-1-1
bmp.Save(outname) ' saves 4-2-2
end if
【问题讨论】: