void LoadImages() {
gunImage = Image.FromFile("images/gun.gif");
for (int i = 0; i < 8; i++) {
attackImages = Image.FromFile("images/attack"+i+".gif",false);
if (i < 7)
ufoImages = Image.FromFile("images/ufo" + i + ".gif",false);
if (i < 4)
explodeImages = Image.FromFile("images/explode" + i + ".gif",false);
}
}
</pre><!–ENDSCRIPT–>
Weird problem [C#]
The following code causes a fatal error in System.Drawing.DLL whenever I compile in Release, but not in Debug:
I know little of C# and it''s ways. However, that hasn''t stopped me from answering anything before, so... :\
It wouldn''t be something like the paths are relative, so they might end up pointing somewhere else in Release rather than Debug. e.g. "./Debug/images/attack0.gif" becomes "./Release/images/attack0.gif" during Release?
Ro_Akira
It wouldn''t be something like the paths are relative, so they might end up pointing somewhere else in Release rather than Debug. e.g. "./Debug/images/attack0.gif" becomes "./Release/images/attack0.gif" during Release?
Ro_Akira
Yeah, but the images folder is present and accounted for in both the release and debug directories.
Is it a fatal error? Or is an exception thrown?
Wrap the code in a try/catch block OR handel this event:
AppDomain.CurrentDomain.UnhandledException
-SniperBoB-
Wrap the code in a try/catch block OR handel this event:
AppDomain.CurrentDomain.UnhandledException
-SniperBoB-
That just breaks it more Basically, if the is thrown then the pictures aren't loaded and there are lots and lots of null reference exceptions
[edited by - jperalta on November 14, 2003 2:49:59 PM]
[edited by - jperalta on November 14, 2003 2:49:59 PM]
quote:
Basically, if the exception? is thrown then the pictures aren''t loaded and there are lots and lots of null reference exceptions
Is there a need for clarification?
Ro_Akira
Hrm... I guess the problem is actually as follows:
If I use the code above to load the images I get a System.OutofMemoryException at gunImage = Image.FromFile("images/gun.gif");
if I replace that with ''gunImage = new Bitmap("images/gun.gif");'' I get a System.ArgumentException (Invalid Parameter Used) in the same place instead of the out of memory exception.
If I use the code above to load the images I get a System.OutofMemoryException at gunImage = Image.FromFile("images/gun.gif");
if I replace that with ''gunImage = new Bitmap("images/gun.gif");'' I get a System.ArgumentException (Invalid Parameter Used) in the same place instead of the out of memory exception.
Again, I''d like to cover myself by declaring that I''ve never touched C#...
"If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception." - MSDN
Strange, but true. Who''d have thought an OutOfMemoryException could indicate that?!
Ro_Akira
"If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception." - MSDN
Strange, but true. Who''d have thought an OutOfMemoryException could indicate that?!
Ro_Akira
from the .NET framework documentation about the Image.FromFile() method:
Yes docs are your friend. I''d find out which file formats and pixel formats GDI+ supports and check your file if it matches them.
quote:.NET Framework Documentation
If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception.
Yes docs are your friend. I''d find out which file formats and pixel formats GDI+ supports and check your file if it matches them.
hmm , hit quote button instead of edit. but anyways, beaten by 7 seconds
[edited by - deathtrap on November 14, 2003 3:44:36 PM]
[edited by - deathtrap on November 14, 2003 3:44:36 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement