|
-
May 11th, 2008, 05:08 PM
#1
Thread Starter
Member
[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!
Last edited by pirate16; May 17th, 2008 at 11:59 AM.
-
May 11th, 2008, 05:37 PM
#2
Re: Save Resources?
i don't think thats possible. my.resources resources are added at design time but can't be added at runtime. you could save the image to your my.application.info.directorypath (where the executable is) then save the filename in my.settings
EDIT: or just save the filename + path in my.settings
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2008, 05:56 PM
#3
Thread Starter
Member
-
May 11th, 2008, 06:05 PM
#4
Re: Save Resources?
to add a my.settings setting
menus - Project-->Properties-->Settings
change Name to "test", Type to string, + scope to user.
to try it add this to your form, then run the project + doubleclick the form:
vb Code:
Private Sub form1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
My.Settings.test = "test"
My.Settings.Save()
MsgBox(My.Settings.test)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2008, 06:10 PM
#5
Thread Starter
Member
Re: Save Resources?
Alright now how will this alloq me to save the image where the .exe is at? What do i have to do to make it so it can save?
Thanks for your help btw
Last edited by pirate16; May 11th, 2008 at 06:13 PM.
-
May 11th, 2008, 06:13 PM
#6
Re: Save Resources?
to save an image anywhere you need to create a new bitmap, then save it.
vb Code:
dim img as new bitmap(filename here)
img.save(new filename here, System.Drawing.Imaging.ImageFormat.Bmp)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2008, 06:19 PM
#7
Thread Starter
Member
Re: Save Resources?
So if i add all that coding its as simple as saying image1.image.save(location) and it will work or is it more complicated? Is there a way you can set this up for me? I can send you my project folder so you can try it out :d.
-
May 11th, 2008, 06:22 PM
#8
Re: Save Resources?
have a try at it yourself. you'll learn more
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2008, 06:28 PM
#9
Thread Starter
Member
Re: Save Resources?
Alright i did it myself but it wont work. I click the button to save the image and it does nothing, what do i have to place in the file name here part of the code? Sorry this is probably really annoying right now.
Last edited by pirate16; May 11th, 2008 at 06:33 PM.
-
May 12th, 2008, 07:20 AM
#10
Re: [2008]Save Resources?
-
May 12th, 2008, 02:34 PM
#11
Thread Starter
Member
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)
-
May 12th, 2008, 10:08 PM
#12
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)
-
May 13th, 2008, 12:53 PM
#13
Thread Starter
Member
Re: [2008]Save Resources?
What if i want the user to choose where to save if i have a save dialog?
-
May 13th, 2008, 12:59 PM
#14
Re: [2008]Save Resources?
Have you read up on the SaveFileDialog on MSDN?
-
May 13th, 2008, 05:42 PM
#15
Thread Starter
Member
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?
-
May 13th, 2008, 05:46 PM
#16
Re: [2008]Save Resources?
read up on the SaveFileDialog on MSDN
it shows you how to avoid errors
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 13th, 2008, 05:54 PM
#17
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 14th, 2008, 01:40 PM
#18
Thread Starter
Member
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"
Last edited by pirate16; May 14th, 2008 at 01:55 PM.
-
May 14th, 2008, 11:38 PM
#19
Re: [2008]Save Resources?
Can u pls post the actual code that u have written in ur project??
-
May 15th, 2008, 03:07 PM
#20
Thread Starter
Member
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.
-
May 15th, 2008, 03:08 PM
#21
Re: [2008]Save Resources?
Is that your exact code? What is the exact error messages?
-
May 15th, 2008, 11:30 PM
#22
Re: [2008]Save Resources?
 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.
-
May 16th, 2008, 03:14 PM
#23
Thread Starter
Member
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!
-
May 16th, 2008, 04:19 PM
#24
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 16th, 2008, 07:33 PM
#25
Thread Starter
Member
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.
-
May 16th, 2008, 07:44 PM
#26
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 16th, 2008, 07:48 PM
#27
Thread Starter
Member
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.
Last edited by pirate16; May 16th, 2008 at 08:08 PM.
-
May 16th, 2008, 08:13 PM
#28
Re: [2008]Save Resources?
 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!
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 16th, 2008, 09:34 PM
#29
Thread Starter
Member
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 . Thanks for this guys i know it was annoying but you dont know how much this helped!!
Last edited by pirate16; May 16th, 2008 at 09:37 PM.
-
May 16th, 2008, 10:42 PM
#30
Re: [2008]Save Resources?
 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  . 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|