المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Poor thumbnail quality when using listview



C# Programming
02-27-2010, 01:01 AM
Hi,

I am having an issue regarding the thumbnail quality and image size. I am using ImageList and ListView to display the images. The problem occurs when i try to create the image from the filepath or from a memorystream object. The quality appears to be blurry.

I did set the quality to "Depth.32Bit". But this still hasnt solve the problem.

I also want to maintain the aspect ratio of the ImageSize dynamically if possible?

Can anyone help kindly me please regarding the above requests/issues?

Here is the code i created behind a datagridview click event.
this.StaffListView.View = View.LargeIcon;
this.StaffListView.LargeImageList = StaffImageList;
StaffImageList.ImageSize = new Size(120, 120);
StaffImageList.ColorDepth = ColorDepth.Depth32Bit;

int pos = StaffDataGridView.CurrentRow.Index;
try {
if (File.Exists(StaffDataGridView.Rows[pos].Cells[1].Value.ToString()))
{
byte[] ImageD = (byte[])StaffDataGridView.Rows[pos].Cells[2].Value;
String RfilePath = StaffsDataGridView.Rows[pos].Cells[1].Value.ToString();

MemoryStream memStream = new MemoryStream(ImageD);
Image image = Image.FromStream(memStream, true);
string filename = fileNameExtractor(RfilePath);
StaffImageList.Images.Add(RfilePath, image);
StaffListView.Items.Add(filename, RfilePath);

}
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}

I also tried not to use the thumbnail thats in the database by creating a thumbnail image from scratch by using an overidden thumbnail method to create a thumbnail and then add that thumbnail to the ListView. This was to check if the problem is with the image in the database but thats where i am having difficulty identifying the where the issue is actually occuring.

I would appreciate if you could get back to me please?

Thanks,