当我使用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
答案 0 :(得分:3)
无法在GDI +中更改色度子采样:
我不得不使用第三方工具(Leadtools RasterImage Library)来实现这一目标。