You might try the following and see if it works or at least increases
the number of bitmaps you can load...
Change your code as follows:
1) Embed the graphic files in you project as a resource (e.g. click on
the file name and change the "build action" property from "content" to
"embedded resource" (I'm assuming these files are inlcuded in the
project as content files)
2) Change you code to mimic the code that follows:
images = new Bitmap[200];
for (int i=0;i<134;i++)
{
images[i] = setbm(fname);
}
private Bitmap setbm()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1)); //assumes pictures
are loaded at design time into picture boxes on form1)
return (System.Drawing.Bitmap)((System.Drawing.Image)(resources.GetObject(fname)));
}
Bill
(E-Mail Removed) (Tony Hsieh) wrote in message news:<(E-Mail Removed)>...
> Hi,
>
> When I try to load anything over 134 bitmaps of size 240x320 into
> memory, I get an ArgumentException in the Bitmap constructor.
> Anything up to 134 works great and once I try to load image 135 it
> fails. The code that works fine is:
>
> images = new Bitmap[photos.Count];
> for (int i=0;i<134;i++)
> {
> images[i] = new Bitmap(photos[i].fileName);
> }
>
> Once i change the 134 to anything greater than 134, I get the
> exception. I find this very strange that is works fine up to a
> certain number. When I look at Memory, I still have 20MB free even
> after loading 134 images. Is there some sort of lock that is
> preventing me from loading more images? Any help be greatly
> appreciated. Thanks so much.
>
> -Tony