【问题标题】:How resize image in vb.net [duplicate]如何在vb.net中调整图像大小[重复]
【发布时间】:2016-03-22 06:05:37
【问题描述】:

我的代码调整图像大小,但它只能减小大小。

 For Each oFile In My.Computer.FileSystem.GetFiles(parm_strTargetPath)
                If oFile.ToString.ToLower.Contains(".png") Or oFile.ToString.ToLower.Contains(".jpg") Or oFile.ToString.ToLower.Contains(".jpeg") Then
                    Dim strFileName = System.IO.Path.GetFileName(oFile)
                    Try
                        Dim original As Image = Image.FromFile(oFile)
                        Dim resized As Image = ResizeImage(original, New Size(h, w))
                        Dim memStream As MemoryStream = New MemoryStream()
                        resized.Save(memStream, ImageFormat.Jpeg)

                        Dim file As New FileStream(result & "/" & strFileName , FileMode.Create, FileAccess.Write)
                        memStream.WriteTo(file)
                        file.Close()
                        memStream.Close()
                    Catch ex As Exception

                    End Try

                End If

            Next

我的图片尺寸:1028x 172,我想调整为500 x 500 但结果是图像大小:500x84 如何将图像从 1028x 172 调整为 500 x 500 ? 谢谢大家。

【问题讨论】:

  • 如果你不保持比例,你会得到一个丑陋的图像。你可以在白色/黑色背景上绘制它。

标签: .net vb.net


【解决方案1】:
 Dim resized As Image = ResizeImage(original, New Size(h, w), False)

而不是

 Dim resized As Image = ResizeImage(original, New Size(h, w))

【讨论】:

  • 是否有更多解释的机会,例如省略 False 的实际作用?
猜你喜欢
  • 2011-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-22
  • 1970-01-01
  • 2013-05-12
  • 2012-05-07
  • 1970-01-01
相关资源
最近更新 更多