Results 1 to 13 of 13

Thread: Run-time error in cStdPicEx2 class

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    765

    Run-time error in cStdPicEx2 class

    I use the cStdPicEx2 class to display multiple pictures on a form.
    But, today it just gave me an error for one specific picture:
    Run-time 91: Object variable or With block variable not set

    The error happened on this line:
    Code:
       Set tpicPNG = cStdPicEx.LoadPictureEx(Pic_File_Path)
    And the picture that causes this error is this:
    http://www.mediafire.com/file/i72v2w...erbed.zip/file

    Please note that:
    1- I have NOT forgotten to do this in MDIForm_Load:
    Code:
       Set cStdPicEx = New stdPicEx2
    2- My process loops through multiple pictures and shows all of them on the same form.
    All pictures are displayed by that same code:
    Code:
       Set tpicPNG = cStdPicEx.LoadPictureEx(Pic_File_Path)
    And all of them (except that one picture) is displayed properly.
    It is only that one picture that gives me the run-time error.

    Please advise
    Thanks.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    I happen to be at work. I can take a look tomorrow after I get home and get some sleep.

    That error simply means that image failed to load. It could be for a host or reasons. When I look at it, I'll post back with the reason, including if the reason is a bug in the class. On the plus-side, good to know that class works well for you 99% of the time
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    VB won't open it, Microsoft Paint and Paint32 and Photo viewer won't open it. Even Mozilla won't open it.

    Conclusion. Likely one or more JPG tags are written incorrectly. This has nothing to do with the class. If Microsoft won't open the file, and the class relies on MS dlls to read the file, then there is nothing to be done. The logical workaround would be to manually parse the JPG, the class does not manually parse JPGs.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: Run-time error in cStdPicEx2 class

    I tried this in Irfanview and it opens fine so I decided to try my Metadata test program.

    Out of FreeImage, GDI+, Windows Imaging Component, Windows Image Acquisition and Stretchblt, only FreeImage will display it. FreeImage reports it as a standard jpg!

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    Quote Originally Posted by Steve Grant View Post
    ... in Irfanview and it opens fine... only FreeImage will display it. FreeImage reports it as a standard jpg!
    Been over a decade since I looked at Irfanview/FreeImage. It very well may manually parse JPG tags and fix/ignore those that don't matter for displaying purposes. Browsing JPG tags is easy to do. If you are really familiar with each tag's structure and what content is valid or not, then tweaking what can be easily tweaked is not a big deal. The only JPG block I ever wrote code to 'correct' was for a specific case where VB would load the JPG but GDI+ would not. That is not the case here.
    Last edited by LaVolpe; May 21st, 2020 at 11:04 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,255

    Re: Run-time error in cStdPicEx2 class

    The image in question is a corrupted one...

    FWIW - the preview-version of the orginal image (from one of the "Stock-images"-sites) is here:
    https://previews.123rf.com/images/hy...-flowerbed.jpg

    And the preview-image under that above link:
    - does have the exact same length in bytes as the corrupted one
    - but does load without probems - also in the "less tolerant" (as in: "security-conscious") JPG-decoders

    So, since the ByteSizes are the same (and for most parts, probably also the contents of the both versions),
    one could now make a "binary-diff-analysis", what exactly was changed in the version which did not load in the less tolerant decoders).

    Don't have the time (or interest) to do that analysis myself - but perhaps someone else will jump in...

    HTH

    Olaf

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    Just a small update. GDI+ actually does load the JPG and reports it as 1300x866 pixels. But it can't display it.

    As Olaf mentioned, need to do some sleuthing to figure out what's broken in the image, if it's that important. Good luck.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: Run-time error in cStdPicEx2 class

    Only the last byte is changed, the correct one has D9 (217) and the wrong one has 4B (75).

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    Quote Originally Posted by Eduardo- View Post
    Only the last byte is changed, the correct one has D9 (217) and the wrong one has 4B (75).
    And changing that last byte fixes the problem. The last 2 bytes of every JPG image should be: 255 & 217. That is the EOI (end of image) tag. Obviously Microsoft and other image processors are enforcing that specification whereas Irfanview simply doesn't care.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,255

    Re: Run-time error in cStdPicEx2 class

    Quote Originally Posted by Eduardo- View Post
    Only the last byte is changed, the correct one has D9 (217) and the wrong one has 4B (75).
    Ah... thanks for "doing the work, and digging this out"...

    Olaf

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    765

    Re: Run-time error in cStdPicEx2 class

    Quote Originally Posted by Schmidt View Post
    The image in question is a corrupted one...

    FWIW - the preview-version of the orginal image (from one of the "Stock-images"-sites) is here:
    https://previews.123rf.com/images/hy...-flowerbed.jpg

    ......
    How did you find the original picture?

    Thanks.

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Run-time error in cStdPicEx2 class

    Well, your zip file name is: "tulips-fresh-spring-flowers-flowerbed"
    If you google that, including the quotes, it's among the first hits and images. Not sure if that's all Olaf did, but it works. And for comparison, one could compare file sizes as Olaf did and even verify the image dimensions.

    Also, it is possible and I didn't look, that the link for the website might be embedded in the JPG itself viewable with Windows & other tools that can read JPG metadata or by just getting curious and opening the JPG in Notepad.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,255

    Re: Run-time error in cStdPicEx2 class

    Quote Originally Posted by LaVolpe View Post
    Well, your zip file name is: "tulips-fresh-spring-flowers-flowerbed"
    If you google that, including the quotes, it's among the first hits and images.
    Not sure if that's all Olaf did, ...
    Yes, that's all I did (though included the 'watermark' "123RF" in addition in my google search-terms).

    I've then just opened the FireFox-Graphics-Preview/Info-Popup (via RightClick on the image in question) -
    and it showed the image-dimensions and image-size (which were identical to the Zipped-Image).

    Olaf

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