![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
pictureboxes and corrupted images
in my pseudo-file manager program, i've noticed that whenever i try to load an image that is corrupt (say, one that hasn't been downloaded completely and is missing some image data) into a picturebox, it invariably causes my program to hang.
i have managed a simple workaround by exiting the subroutine upon error (thus just displaying whatever image was previously displayed), which works great for 90% of the corrupted images that pass through the program but every so often i still come across a corrupted image that brings the program to its knees. any of you guys know/can think of a more surefire solution to dealing with such errors? thanks |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
Use some GD library DLLs written in C++ to tie into VB and check to see if an image has all the required data to be displayed..
__________________
|
|
|
|
|
|
#3 | |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
seriously, none of that computes. what are GD library DLLs, and how much C++ do i have to learn in order to accomplish this simple(?) task? i know -nothing- about it at this point. |
|
|
|
|
|
|
#4 |
|
Expert Programmer
|
Yeah, call on a DLL, or better DirectX to render your images. The GDI libraries that are in the VB runtime are incredibly primitive, as they were written for windows 98 and can only handle a few file formats.
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
hah!
i've figured out the problem. it only crashes when i load a corrupt image and imagebox.stretch = true. if imagebox.stretch = false, then my error handler is able to pick it up. stretching corrupt images is the cause of the problem. so what i've done is made an invisible imagebox (.stretch = false) that i load all pictures into first. if the errorhandler doesn't detect anything wrong with it, the program loads the image into my main imagebox (.stretch = true) and there are no problems with it beyond that. i love you guys, but sometimes, i love myself more ![]() |
|
|
|
|
|
#6 |
|
Expert Programmer
|
LOL! Good way to get around the problem.
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
hmm well it seems my method isn't quite as infallable as i thought, i still get crashes once in a blue moon.
what's weird about it is this though- as far as i've tested, the program NEVER crashes if i make a breakpoint at the line of code where the image is first loaded into the testing (stretch=false) imagebox. the program halts before loading the image, i push F8 to allow the program to execute that line of code to load the image, and the program automatically jumps to the errorhandler before going to the next line. here's some pseudo-code; the asterisk is the breakpoint: imgtestingbox.stretch = false
imgmaindisplay.stretch = true
on error goto errorhandler
*imgtestingbox.picture = loadpicture(filename)
imgmaindisplay.picture = loadpicture(filename)
rest of code goes here
exit sub
errorhandler:
msgbox("there was an error")
exit subi suspect that the program starts loading the picture into the problematic stretch=true box before the program realizes the one in the stretch=false box is going to set off an error. i came to this conclusion because i seem to have more problems with this on my p4 than my p3. is there a way to use an if/then statement to say "if [error happens] then [exit sub] else [continue]" right after loading the picture into the imgtestingbox? "on error..." just doesn't seem to cut it. Last edited by chepfaust; Apr 24th, 2005 at 2:49 PM. |
|
|
|
|
|
#8 |
|
Expert Programmer
|
You want:
Try (do something) Catch Err as Exception (if an error occurs, Err defines it) Finally (always executed) End Try |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
very interesting; you never seem to run out of completely new concepts i've never seen before. thanks very much; i'll try implementing that when i get a chance later on
![]() |
|
|
|
|
|
#10 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|