你如何保存4-2-2在.NET中的JPEG和高品质的? [英] How do you save a jpeg with 4-2-2 and high quality in .net?

查看:130
本文介绍了你如何保存4-2-2在.NET中的JPEG和高品质的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我省使用bitmap.save一个JPG文件,它保存为JPEG 4-1-1时,我指定了EN codeR和质量,但4-2-2的时候我不知道。我想将其保存为4-2-2具有较高的质量比默认的。这是可能的使用bitmap.save?难道我通过节约用4-1-1失去什么?

 昏暗的BMP位图作为
昏暗的EP作为新恩coderParameters(1)
昏暗SYS codeCS()作为图像codecInfo
昏暗的JPG codeC,中华网作为图像codecInfo

SYS codeCS =图片codecInfo.GetImageEn codeRS()

获得JPG codeC
JPG codeC =无
对于每一个疾病预防控制中心在sys codeCS
  如果的String.Compare(cdc.MimeType,图像/ JPEG,真)= 0然后
    JPG codeC = CDC
    退出对于
  结束如果
下一步疾病预防控制中心

如果JPG codeC状态并没有任何然后
  ep.Param(0)=新恩coderParameter(恩coder.Quality,97)
  BMP = Bitmap.FromFile(文件名)
  bmp.Save(outname,JPG codeC,EP)节约4-1-1
  bmp.Save(outname)节约4-2-2
如果结束
 

解决方案

这是不可能改变色度抽样的GDI +:

我不得不使用第三方工具(LEADTOOLS RasterImage库)来实现这一点。

When I save a jpg file using bitmap.save, it saves as jpeg 4-1-1 when I specify the encoder and quality, but as 4-2-2 when I don't. I would like to save it as 4-2-2 with a higher quality than the default. Is that possible using bitmap.save? Do I lose anything by saving with 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

解决方案

It is not possible to change chroma subsampling in GDI+:

I had to use a third party tool (Leadtools RasterImage Library) to accomplish this.

这篇关于你如何保存4-2-2在.NET中的JPEG和高品质的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆