Results 1 to 5 of 5

Thread: Save image using Image Edit control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    17

    Save image using Image Edit control

    Hi,

    I'm trying to save a picture using the image edit control that comes with VB6. I am using the SaveAs method to save the .jpg file under another name but I keep getting a 321 error Invalid File Format.

    Here's my Code:
    ImgEdit1.SaveAs "C:\My Documents\" & Text1.Text & ".jpg", wiFileTypeJPG

    Any help is appreciated

    THanks
    ML

  2. #2
    Addicted Member Bazza81's Avatar
    Join Date
    Apr 2001
    Location
    Nottingham, UK
    Posts
    203
    Unless you learn huffman coding and write yourself a .jpeg algorithm your not going to be able to save it as anything else other than a .bmp!
    Who needs rhetorical questions anyway?


    Bazza NET - The place you want to be!

  3. #3
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    This works for me. With this control, I have always had better luck using the using numbers instead of any constants.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. Dim strFile As String
    5.  
    6.     strFile = "C:\My Documents\" & Text1.Text & ".jpg"
    7.     ImgEdit1.SaveAs strFile, 6, , 6, 1024
    8. End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    17
    Thanks for the help but I am still getting the same error message:
    Run Time error '321':

    Invalid File Format

    Unable to execute the SaveAs method

    Here's my code for the Save button on my form:

    Private Sub cmdSave_Click()
    Dim strFile As String

    If Text1.Text = "" Then
    MsgBox "No File Name Entered", vbOKOnly
    Else:
    strFile = "C:\My Documents\" & Text1.Text & ".jpg"
    ImgEdit1.SaveAs strFile, 6, , 6, 1024
    End If
    End Sub

    These are .jpg pictures to begin with so I am not trying to save them in a different format, just trying to rename them. I can get it to work as long as I don't try to save it to the .jpg format.

  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I'm not sure what the difference is, but at home where I'm running Win2K and VB with SP5 it runs fine. At work I'm using a Win98 machine and VB with SP4 and it comes up with the same error as what you are getting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width