在VB.net下如何修改JPG图片的质量?

nofound007 2009-09-01 09:59:57
如题

net中自带System.Drawing.Imaging空间,如何在此空间下修改图片质量?要实现可以按百分数的设置,就像ACDSEE一样。
...全文
211 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fairy4 2009-09-02
  • 打赏
  • 举报
回复


'定義
Shared htmimes As New Hashtable
'初始化
#Region "htmimes[.jpe]=image/jpeg"
Shared Sub New()

htmimes(".jpe") = "image/jpeg"
htmimes(".gif") = "image/gif"
htmimes(".jpeg") = "image/jpeg"
htmimes(".jpg") = "image/jpeg"
htmimes(".png") = "image/png"
htmimes(".tif") = "image/tiff"
htmimes(".tiff") = "image/tiff"
htmimes(".bmp") = "image/bmp"

End Sub
#End Region
nofound007 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 fairy4 的回复:]
VB.NET codePrivateSub ThumbnailImage(ByVal newimageAs Image,ByVal intNewWidthAsInteger,ByVal intNewHeightAsInteger,ByVal mFileExtNameAsString,ByVal levelAsInteger,ByVal SavePathAsString)Try' Dim newIm¡­
[/Quote]


htmimes是什么函数啊?
nofound007 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 forrest23 的回复:]
JPG图片的质量 具体是指的什么?
[/Quote]

图片质量指图片的 Quality。

二楼的兄弟子程序有点意思了,但还得消化,有没有更明了一点,在下菜鸟一只
fairy4 2009-09-01
  • 打赏
  • 举报
回复

Private Shared Function GetCodecInfo(ByVal mimeType As String) As ImageCodecInfo
Dim CodecInfo As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()
For Each ici As ImageCodecInfo In CodecInfo
If ici.MimeType = mimeType Then
Return ici
End If
Next
Return Nothing
End Function
fairy4 2009-09-01
  • 打赏
  • 举报
回复

Private Sub ThumbnailImage(ByVal newimage As Image, ByVal intNewWidth As Integer, ByVal intNewHeight As Integer, ByVal mFileExtName As String, ByVal level As Integer, ByVal SavePath As String)
Try


' Dim newImage As Image = Me.PictureBox1.Image
Dim ici As ImageCodecInfo = GetCodecInfo(DirectCast(htmimes(mFileExtName), String))
Dim parameters As New EncoderParameters(1)

parameters.Param(0) = New EncoderParameter(Encoder.Quality, CLng(level))

Dim objNewBitMap As New Bitmap(intNewWidth, intNewHeight, PixelFormat.Format32bppArgb)
'从指定的 Image 对象创建新 Graphics 对象
Dim objGraphics As Graphics = Graphics.FromImage(objNewBitMap)
'清除整个绘图面并以透明背景色填充
objGraphics.Clear(Color.Transparent)
'在指定位置并且按指定大小绘制 原图片 对象
objGraphics.DrawImage(newimage, New Rectangle(0, 0, intNewWidth, intNewHeight))
objNewBitMap.Save(SavePath, ici, parameters)
objNewBitMap.Dispose()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Forrest23 2009-09-01
  • 打赏
  • 举报
回复
JPG图片的质量 具体是指的什么?

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧