Results 1 to 7 of 7

Thread: Image Validate and Save JPG

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    1

    Exclamation

    I made a program that looks for images in a certin folder including subfolders to detect doubles.

    My problem is that as soon as a picture (JPG or GIF) is not complete (aborted download, etc) the LoadPicture hangs up and the program crashes with out generating any error message (so On Error won't work).

    How can I check that a picture is valid before loading it?

    I also have a problem saving pictures in other formats than BMP. Is there any nice OCX or anything that can sort me out?

    Cheers..

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I'd also like to know how to validate an image so VB won't crash.


  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I'd like to know how to dig up dead threads

    anyway... never seen the problem, but I have an idea: how about using a very simple DLL which just loads the picture into an object variable (& sets it to nothing after), then returns True.

    In the calling program you can just make sure that true is returned, if not (or if it returns an error) then the picture isnt safe.

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I was searching for an answer but didn't find one.

    And when it does error it consumes CPU.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    ah.. pants!

    in that case I guess you'll have to check the file format yourself to make sure that all the markers are there/there is enough data.

    I don't know the format... best to ask Wotsit

  6. #6
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    The problem is I don't know exactly what causes the error in the LoadPicture function.

    And I'll have to be validating several file types.


  7. #7
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    load the file in binary mode and get the header. (check wotsit.org)

    if its 8-bit filesize should be width*height+len(header)
    if its 32-bit it should be width*height*3+len(header)
    dunno about the others...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

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