Out of memory with multi images in one picturebox
Posted
by Nikom
on Stack Overflow
See other posts from Stack Overflow
or by Nikom
Published on 2010-03-15T18:43:23Z
Indexed on
2010/03/15
18:49 UTC
Read the original article
Hit count: 566
Hi, ive problem with out of memory when i
m trying load few images into one picturebox. Pls Help :)
public void button2_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.ShowDialog();
string selected = dialog.SelectedPath;
string[] imageFileList = Directory.GetFiles(selected);
int iCtr = 0,zCtr = 0;
foreach(string imageFile in imageFileList)
{
if (Image.FromFile(imageFile) != null)
{
Image.FromFile(imageFile).Dispose();
}
PictureBox eachPictureBox = new PictureBox();
eachPictureBox.Size = new Size(100,100);
// if (iCtr % 8 == 0)
//{
// zCtr++;
// iCtr = 0;
//}
eachPictureBox.Location = new Point(iCtr * 100 + 1, 1);
eachPictureBox.Image = Image.FromFile(imageFile);
iCtr++;
panel1.Controls.Add(eachPictureBox);
}
}`enter code here`
© Stack Overflow or respective owner