下面的代码将填充的表单另存为.JPG图像。但是,它需要能够在IE浏览器中打开。未通过代码生成的任何其他.JPG图像都会打开,如果我更改代码以另存为.png,它也会在IE浏览器中打开。我需要对.JPG / .JPEG做一些特殊的事情吗?
代码:
Private Sub btnImage_Click(sender As Object, e As EventArgs) Handles btnImage.Click
Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
dialog.SelectedPath = ""
dialog.Description = "Select Save Location"
If dialog.ShowDialog() = DialogResult.OK Then
Savepath = dialog.SelectedPath
SaveName = txtPN.Text
If Not SaveName = "" Then
Using bm As New Bitmap(HUD.pnlMain.Width, HUD.pnlMain.Height, Imaging.PixelFormat.Format16bppRgb555)
HUD.pnlMain.DrawToBitmap(bm, New Rectangle(0, 0, bm.Width, bm.Height))
bm.Save(Savepath & "\" & SaveName & ".JPG") '.PNG
End Using
MsgBox("Image was saved as " & SaveName & " at " & Savepath)
Else
Exit Sub
End If
Exit Sub
End If
End Sub
答案 0 :(得分:1)
也许您应该尝试passing the format。
bm.Save(Savepath & "\" & SaveName & ".JPG", System.Drawing.Imaging.ImageFormat.Jpeg)
此外,您可以使用Path class创建文件的完整路径。