【问题标题】:How do you save a jpeg with 4-2-2 and high quality in .net?如何在 .net 中保存具有 4-2-2 和高质量的 jpeg?
【发布时间】: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

【问题讨论】:

    标签: .net image bitmap jpeg


    【解决方案1】:

    无法在 GDI+ 中更改色度二次采样:

    我必须使用第三方工具(Leadtools RasterImage Library)来完成此操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-07
      • 2017-06-14
      • 2011-12-16
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 2018-02-16
      • 2011-08-17
      相关资源
      最近更新 更多