I select Multiple images from file and show their thumbnails in the panel. here is code i write for this::
//files is string type array Containing the image Location
//left, top, picWidth, picHeight are int variables.
foreach(string file in files)
{
Bitmap bit = new Bitmap(file);
ratio = (double)bit.Width / (double)picWidth;
PictureBox picBox = new PictureBox();
picBox.Name = file;
if (left + picWidth > this.Panel2.Width)
{
left = 10;
top += picHeight + 10;
}
picBox.Size = new Size(picWidth, picHeight);
picBox.Image = bit.GetThumbnailImage(picWidth,(int)((double) bit.Height / ratio), null, System.IntPtr.Zero);
picBox.SizeMode = PictureBoxSizeMode.Zoom;
picBox.Location = new Point(left, top);
this.Panel2.Controls.Add(picBox);
picBox.BorderStyle = BorderStyle.FixedSingle;
Application.DoEvents();
left += picWidth + 10;
}
Sir, My Question is that how can i enhance the speed of my code. Is there any way that i use the treads and it increase the speed of making and showing of thumbnails. or any other way??
i am very thankful to you in advnace..