V
Vagabond Software
I'm trying to display thumbnail images in a Listview that look more like the
Windows thumbnail view. Everything is working pretty good, but my
thumbnails are decidedly not like the Windows thumbnails.
View the following snapshot to compare the Windows thumbnails (top) to my
ListView thumbnails (bottom):
http://home.san.rr.com/vagabondia/images/tmp/sample.gif
It looks like the Windows thumbnails retain their proportion by, perhaps,
using some kind of "spacer" image on the top and bottom to create the
"letterbox" effect. I try and maintain the aspect ratio of the original
image, but it stretches into the height and width determined by the
ImageList. Here is my code to get thumbnails from the original images:
--- code ---
thumbnail = getThumbnail(originalImage, imglstStock.ImageSize.Width);
private Image getThumbnail(System.Drawing.Image image, int desiredWidth)
{
int imgWidth = image.Width;
int imgHeight = image.Height;
decimal ratio = (decimal) desiredWidth / imgWidth;
int desiredHeight = Convert.ToInt32(ratio * imgHeight);
Image.GetThumbnailImageAbort thumbCallback = new
Image.GetThumbnailImageAbort(thumbnailCallback);
Image thumb = image.GetThumbnailImage(desiredWidth, desiredHeight,
thumbCallback, IntPtr.Zero);
return thumb;
}
private bool thumbnailCallback()
{
return false;
}
--- code end ---
Any suggestions, advice, or links to reading material would be greatly
appreciated.
Carl
Windows thumbnail view. Everything is working pretty good, but my
thumbnails are decidedly not like the Windows thumbnails.
View the following snapshot to compare the Windows thumbnails (top) to my
ListView thumbnails (bottom):
http://home.san.rr.com/vagabondia/images/tmp/sample.gif
It looks like the Windows thumbnails retain their proportion by, perhaps,
using some kind of "spacer" image on the top and bottom to create the
"letterbox" effect. I try and maintain the aspect ratio of the original
image, but it stretches into the height and width determined by the
ImageList. Here is my code to get thumbnails from the original images:
--- code ---
thumbnail = getThumbnail(originalImage, imglstStock.ImageSize.Width);
private Image getThumbnail(System.Drawing.Image image, int desiredWidth)
{
int imgWidth = image.Width;
int imgHeight = image.Height;
decimal ratio = (decimal) desiredWidth / imgWidth;
int desiredHeight = Convert.ToInt32(ratio * imgHeight);
Image.GetThumbnailImageAbort thumbCallback = new
Image.GetThumbnailImageAbort(thumbnailCallback);
Image thumb = image.GetThumbnailImage(desiredWidth, desiredHeight,
thumbCallback, IntPtr.Zero);
return thumb;
}
private bool thumbnailCallback()
{
return false;
}
--- code end ---
Any suggestions, advice, or links to reading material would be greatly
appreciated.
Carl