Boa*_*ats 3 vb.net system.drawing savefiledialog
我已经可以将文件另存为.jpeg,但是图像无法加载,有人建议吗?
Private Sub Btnconfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnconfirm.Click
MsgBox("A receipt will now be saved to your files", vbOKOnly, "Thank you for your purchase")
SaveFileDialog1.ShowDialog()
MsgBox("Thank you for choosing Tiny Theatre, have a nice day.", vbOKOnly, "Thank you")
Me.Close()
End Sub
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
Dim FileToSaveAs As String = SaveFileDialog1.FileName
Dim objwriter As New System.IO.StreamWriter(FileToSaveAs)
objwriter.Write(PictureBox1)
objwriter.Close()
End Sub
Run Code Online (Sandbox Code Playgroud)
没有尝试过,但是可以这样做吗?
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
Dim FileToSaveAs As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Temp, SaveFileDialog1.FileName)
PictureBox1.Image.Save(FileToSaveAs, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Run Code Online (Sandbox Code Playgroud)
如果需要设置编码器参数(如jpeg压缩),则需要Save方法的重载。请参阅http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspx和http://msdn.microsoft.com/en-us/library/system.drawing.image .aspx
所提供的代码将图片框控件以序列化的形式保存到扩展名为jpeg的文件中。将text.txt文件重命名为text.jpg不会使其成为有效的jpg图像。是一样的
| 归档时间: |
|
| 查看次数: |
44005 次 |
| 最近记录: |