[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Saving and loading image files

Posted on 2004-11-01
8
Medium Priority
?
184 Views
Last Modified: 2010-04-23
Hi,
I have a listbox(lstContacts) that displays my contacts. When I choose a contact from the list and then click "View" button , data related to him/her appears on left side of screen. On the left side of the screen, there's also an imagebox that displays his/her picture in an imagebox called picPhoto. Under that imagebox, button"Edit Picture" does the following.

 With dlgChoosePic
            .Filter = "Jpeg Files (*.jpg)|*.jpg|Gif Files (*.gif)|*.gif)|Bitmap Files (*.bmp)|*.bmp)"
            .Title = "Choose an image to use"
            If .ShowDialog <> DialogResult.OK Then Return

            If .FileName <> "" Then
                picPhoto.Image = Image.FromFile(.FileName)
            End If
        End With

As you'll see, i want user to be able to choose bmp's, jpeg's and gif's. But this does not save the image. How will i make it so that, when a contact's picture is selected after clicking "edit picture", program will pop up a message box asking "are you sure you want to use this picture as contact's display picture?" and when user clicks yes, it will automatically save the picture.
Later, when a contact is selected and "View" button is clicked, his/her picture in imagebox will appear automatically.
I'd really appreciate if you could give exact code for my need.
Thanks.
0
Comment
Question by:aeusta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12466640
>> When I choose a contact from the list and then click "View" button , data related to him/her appears on left side of screen.

You need to store the path to the image (dlgChoosePic.FileName) in the structure that holds the rest of the data for that contact.

Where and how is this data stored?

~IM
0
 

Author Comment

by:aeusta
ID: 12466743
Structure Contact

        Dim LName As String
        Dim FName As String
        Dim Category As String
        Dim Company As String
        Dim HPhone As String
        Dim WPhone As String
        Dim FPhone As String
        Dim MPhone As String
        Dim Email As String
        Dim MSN As String
        Dim AIM As String
        Dim Web As String
        Dim HAddress As String
        Dim HCity As String
        Dim HState As String
        Dim HZip As String
        Dim HCountry As String
        Dim WAddress As String
        Dim WCity As String
        Dim WState As String
        Dim WZip As String
        Dim WCountry As String

    End Structure  


This is the structure for contact. So far, i did nothing to save the image nor path to the image. I guess i need to say
Dim imagePath as String
into the structure?
I'm kinda confused, never dealt with images before.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 600 total points
ID: 12466796
Right.  Adding imagePath to the structure would work just fine.

Then, when you load the data for that contact, you can check the imagePath value.  If it is not blank, then load the image in the same way as you did from the "Edit Picture" button, except that you use your stored image fileName instead of the one selected by the user from the dialog.

~IM
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12466816
>> I'm kinda confused, never dealt with images before.

With this approach you won't be saving the actual image in your structure, but only the full path and filename of the image.

~IM
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12470145
I think you also want to save the image is it ??
May be when user selects the image and says OK yuo would like to save the image in a separate location and just store the name in the structure.

You can use picPhoto.Image.Save(Path) to save the image

0
 

Author Comment

by:aeusta
ID: 12476487
Idle Mind,
That's a smart way actually but i want the program to save the picture.

Arif Eqbal,
I tried : picPhoto.Image.Save("..\"), it gave following error.
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll

Additional information: A generic error occurred in GDI+.

Then i tried, picPhoto.Image.Save("..\pic") beucase tooltip says "inside paranthesis, i must write filename as String" , but this code does nothing, it does not work.
I would be surprised if it was this easy to save a file btw.
0
 

Author Comment

by:aeusta
ID: 12476663
I dont know if you guys use MSN messenger but what i exactly want is the "display picture" feature of msn messenger but without internet stuff.
When i click "edit picture" button, I should be able to browse folders, choose a picture, and the picture i chose must automatically appear in imagebox everytime i load contact's info.
I hope i'm clear enough.
0
 

Author Comment

by:aeusta
ID: 12487925
Idle Mind,
I gave up adding that function but gave you the points for your efforts.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question