0

Searching for a way to extract Shell Thumbnails for a windows application, I ran into this post and its very useful answer by AMissico: C# get thumbnail from file via windows api The sample project that solves the problem posted above can be downloaded here: http://cid-7178d2c79ba0a7e3.office.live.com/self.aspx/.Public/ShellThumbnail.zip (I hope the original poster won't mind ...)

I've been able to modify the code posted by AMissico to keep the original aspect ratio of the images, but what I would like to do is offer a crop option, and mention the top-left point to start cropping from.

The sample project posted by AMissico uses the IExtractImage interface, with methods GetLocation and Extract. The GetLocation method accepts a size parameter, but I haven't found any way to add a starting point for the cropped image to it.

I would appreciate any help in doing this. Thanks!

Community
  • 1
  • 1
mocinha
  • 3
  • 1

1 Answers1

0

I don't think there is a built-in way to obtain the thumbnail cropped. The size parameter is used for obtaining an image of a certain size (which can be the thumbnail image resized to that certain size or a completely different image for some ranges of the size parameter).

However, in the end, after obtaining the thumbnail image, why not crop that image right after obtaining and before first using it?

Andrei Pana
  • 4,484
  • 1
  • 26
  • 27
  • That is an excellent idea - I already applied it to my problem and it worked perfectly. Thanks! – mocinha Jan 31 '11 at 16:32
  • I want to add that I had some trouble with the original method used for getting the thumbnails - AMissico's project was blocking the original files - and since I wasn't able to understand why, I started looking for another solution. In the original post I found a much easier way to get the thumbnail using the ShellFile class; here is the two lines of code to replace the entire project: `ShellFile shellFile = ShellFile.FromFilePath(pathToYourFile); Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;` – mocinha Apr 20 '11 at 15:13