跳到主要內容

發表文章

目前顯示的是 9月, 2008的文章

[.Net]JPG品質調整

Imports System.Drawing.Imaging Sub SaveJPG()  Dim Image as Bitmap = New Bitmap(OrigianalImageFile)   '設定壓縮品質90檔案大小約是100的一半 但是畫質還是很不錯  Dim quality As Integer = 90  Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)  '取得編碼格式   Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)  Dim encoderParams As New EncoderParameters(1)  encoderParams.Param(0) = qualityParam  Image.Save(NewImageFile, jgpEncoder, encoderParams) End Sub '取得編碼格式的副程式 Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo  Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()  Dim codec As ImageCodecInfo   For Each codec In codecs    If codec.FormatID = format.Guid Then     Return codec    End If   Next codec  Return Nothing End Function 參考資料: MSDN