[RESOLVED][2008]Save Resources?
I was wondering if there was a way to save an image(a resource of the program)? My program now what it does is you select the image you want to see but right now there is no way to save it. How can i do it if being able to save resources is not an option?
This is how i load the resoruce.bitmap:
Case "Widescreen"
picturebox1.Image = My.Resources.noImageAvailable
Based on that i want the user to be able to save the image that is placed into the picture box!
Re: [2008]Save Resources?
Re: [2008]Save Resources?
The code he game me to use to save it here:
1.
dim img as new bitmap(filename here)
2.
img.save(new filename here, System.Drawing.Imaging.ImageFormat.Bmp)
Re: [2008]Save Resources?
If you want to just save image of picture box then following one line code is enough. You can choose different formats to save form ImageFormat.
Code:
PictureBox1.Image.Save("c:\test.bmp", Imaging.ImageFormat.Bmp)
Re: [2008]Save Resources?
What if i want the user to choose where to save if i have a save dialog?
Re: [2008]Save Resources?
Have you read up on the SaveFileDialog on MSDN?
Re: [2008]Save Resources?
Yes i know how to use it but how would i place that code into it to make sure it does the right thing without error?
Re: [2008]Save Resources?
read up on the SaveFileDialog on MSDN
it shows you how to avoid errors
Re: [2008]Save Resources?
vb Code:
Private Sub button1_Click(sender As Object, e As System.EventArgs)
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "bmp files (*.bmp)|*.bmp|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
img.save(saveFileDialog1.filename, Imaging.ImageFormat.Bmp)
End If
End Sub
Re: [2008]Save Resources?
I keep getting Dim img As New Bitmap(filename here) error with here underlined blue Comma or expression needed and img underlined blue with error "declaration expected"
Re: [2008]Save Resources?
Can u pls post the actual code that u have written in ur project??
Re: [2008]Save Resources?
dim img as new bitmap(filename here)
img.save(new filename here, System.Drawing.Imaging.ImageFormat.Bmp)
This is the code where i get the error.
Re: [2008]Save Resources?
Is that your exact code? What is the exact error messages?
Re: [2008]Save Resources?
Quote:
Originally Posted by pirate16
dim img as new bitmap(filename here)
img.save(new filename here, System.Drawing.Imaging.ImageFormat.Bmp)
This is the code where i get the error.
Have u seen the code posted .paul.? Use that code.
Re: [2008]Save Resources?
I did use that code lol thats the code giving me the error. The error is:
(filename here) here is underlined blue and it says comma, ')', or a valid expression continuation expected.
and img.save(new filename here) file name here underlined with same error and img udnerlined with error: name img is not declared although i did put dim img!
Re: [2008]Save Resources?
post your COMPLETE code + someone might help you.
looking at your previous posts in this thread it looks like you've got confused.
Re: [2008]Save Resources?
Code:
Public Class Form1
Dim img As New Bitmap(filename here)
Private documentTitle As String
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Select Case ListBox1.SelectedItem.ToString()
Case "Save"
PictureBox1.Image = My.Resources.Save_Button
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "bmp files (*.bmp)|*.bmp|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
img.save(saveFileDialog1.FileName, Imaging.ImageFormat.Bmp)
documentTitle = saveFileDialog1.FileName
End If
End Sub
End Class
Dim img As New Bitmap(filename here) - THIS IS WHERE I GET ERROR on the here part. The image one is no longer there but yeah.
Re: [2008]Save Resources?
vb Code:
Dim img As New Bitmap(filename here)
you're supposed to substitute - filename here - for the filename of the image file.
Re: [2008]Save Resources?
I figured that much lmao. *smack self in head* so basically every time the user changes the image in the list box i dim it as the new image name? Also when i hit the save button it only saves the one image i set up in the dim image as new bitmap(my.resources.save_button). IS there a way to save save as whats in the image box? Cause when i say dim image as new bitmap(picturebox1.image) it comes up with some handling error.
Re: [2008]Save Resources?
Quote:
Originally Posted by Deepak Sakpal
If you want to just save image of picture box then following one line code is enough. You can choose different formats to save form ImageFormat.
Code:
PictureBox1.Image.Save("c:\test.bmp", Imaging.ImageFormat.Bmp)
Deepak Sakpal told you how to do that 4 days ago!
Re: [2008]Save Resources?
I know but how do i set that up so the user can select where to save? Nevermind i figured it out :D. Thanks for this guys i know it was annoying but you dont know how much this helped!!
Re: [2008]Save Resources?
Quote:
Originally Posted by pirate16
I know but how do i set that up so the user can select where to save? Nevermind i figured it out :D. Thanks for this guys i know it was annoying but you dont know how much this helped!!
ok then you can now mark the thread as resolved and don't forget to rate our post :D