Foxtable(狐表)用户栏目专家坐堂 → 图片压缩


  共有4347人关注过本帖树形打印复制链接

主题:图片压缩

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/2 17:54:00 [显示全部帖子]

mark 压缩图片

 

Dim img As image = getimage("g:\aaa.jpg")
Dim bmp As new bitmap(img.width, img.height)
Dim g = graphics.fromimage(bmp)
g.DrawImage(img, 0, 0, img.Width, img.Height)
Dim jpgEncoder As ImageCodecInfo
Dim codecs() As ImageCodecInfo = ImageCodecInfo.GetImageDecoders
For Each codec As ImageCodecInfo In codecs
    If (codec.FormatID = ImageFormat.Jpeg.Guid) Then
        jpgEncoder = codec
        Exit For
    End If
Next
 Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
Dim myEncoderParameters As EncoderParameters = New EncoderParameters(1)
Dim myEncoderParameter As EncoderParameter = New EncoderParameter(myEncoder, 30) ' 质量级别 0 对应于最大压缩,而质量级别 100 对应于最小压缩
myEncoderParameters.Param(0) = myEncoderParameter

bmp.Save("g:\压缩图aaa.jpg", jpgEncoder, myEncoderParameters)
bmp.dispose

g.dispose

[此贴子已经被作者于2017/6/7 15:59:28编辑过]

 回到顶部