[英]Convert JPEG or PNG to SVG format on VB.net/C# or Objective-C
[英]Converting JPEG to PNG in VB.NET(Saved output has no extension)
這是我轉換圖像的代碼
Public Sub ConvertImage(ByVal Filename As String, _
ByVal DesiredFormat As System.Drawing.Imaging.ImageFormat, _
ByVal NewFilename As String)
NewFilename = "ConvertedToPNG-" + NewFilename + "-" + Format(Date.Now, "MMMMddyyyyhhmmtt")
Try
Dim imgFile As System.Drawing.Image = _
System.Drawing.Image.FromFile(Filename)
imgFile.Save(txtPNGFileDestination.Text & "\" & NewFilename, DesiredFormat)
Catch ex As Exception
Throw ex
End Try
End Sub
它運行正常,但保存的圖像沒有 PNG 文件擴展名,因此它只是一個文件。 我做錯了什么嗎?
謝謝你的幫助
只需將擴展名添加到 NewFileName。 您還需要聲明 NewFileName "ByRef":
Public Sub ConvertImage(ByVal Filename As String, ByVal DesiredFormat As System.Drawing.Imaging.ImageFormat, ByRef NewFilename As String)
NewFilename = "ConvertedToPNG-" + NewFilename + "-" + Format(Date.Now, "MMMMddyyyyhhmmtt") & "." & DesiredFormat.ToString
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.