?
Solved

Saving the same picture in different folder using VB6

Posted on 2003-11-26
5
Medium Priority
?
564 Views
Last Modified: 2008-03-17
Ok, this is what I want to happen in my program, I have this picture box or image box inside my form1, and there were 2 buttons on it, one is Open Picture, and the other is Save picture. Once I press the Open Picture, I can open any picture(jpeg or gif) in any folder in my drive C, for example I've open a jpeg image in my "My documents" folder. When I press Save button, the picture will be save in my "C:\Image\" folder. I've already done everything expect the save button....I'm having problem saving the image file to a different folder. Any help will do. Thanks in Advance.
0
Comment
Question by:bawasi
5 Comments
 
LVL 24

Assisted Solution

by:shivsa
shivsa earned 100 total points
ID: 9829961
try this link.
-----------------------
http://www.informit.com/isapi/product_id~{3EBD1237-3C91-4CF3-A0BA-EB3976CD978B}/element_id~{43EC34DD-E564-4F64-9585-614F65728ED6}/st~{8B377B75-8B63-4AEA-BEA1-4917BA2DDED0}/session_id~{30F0AE92-7082-4D72-852E-64655747A316}/content/articlex.asp#Heading3
0
 
LVL 8

Assisted Solution

by:_corey_
_corey_ earned 100 total points
ID: 9830240
Will there be any changes to the picture?  Do you want to save the data that is loaded into the display box or just copy the file from one location to another?

If you like, you could simply take the filename that you used to open it, and open it manually, open the new location, and read/write until you are done.

0
 

Author Comment

by:bawasi
ID: 9830437
No there will be no changes in the picture. And yes what is shown in the display box is what i want to save into different folder. And I want to the program to save it for me to the different folder.

Actually, in saving the image that is being displayed in the display box, if it is possible, I dont want to use a dialog box, I want it to be automatically save to the path that I specify in my code...for example "c:\images\". thats all.
0
 
LVL 6

Accepted Solution

by:
mirzas earned 800 total points
ID: 9831456
Could this help?


Option Explicit

Private Sub OpenAndSave(ByRef targetPictureBox As PictureBox, ByVal fOpenPath, ByVal fSavePath As String)
    targetPictureBox.Picture = LoadPicture(fOpenPath)
    Call FileCopy(fOpenPath, IncludeSlash(fSavePath) & GetName(fOpenPath))
End Sub


Function GetName(ByVal s As String) As String
    Dim i As Integer
    Dim tmp As String
   
    tmp = ""
    i = Len(s)
    Do While i > 1
        If Mid(s, i, 1) = "\" Then
            i = 0
        Else
            tmp = Mid(s, i, 1) & tmp
        End If
        i = i - 1
    Loop
    GetName = tmp
   
End Function

Function IncludeSlash(ByVal s As String) As String
   
    If Mid(s, Len(s), 1) <> "\" Then
        IncludeSlash = s & "\"
    Else
        IncludeSlash = s
    End If
End Function

Private Sub cmdOpen_Click()
    'open and copy
    Call OpenAndSave(Picture1, "C:\test.jpg", "D:\")
End Sub
0
 

Expert Comment

by:lonsoft
ID: 9894368
Only one line code:
  SavePicture Picture1.Picture ,"C:\Image\yourNewFileName.bmp"
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

839 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