Saturday, April 15, 2006

I Love the Constant Discovery... (Image.GetThumbnailImage)

Recently I built a .Net 2 app that hosts a user defined list of Remote Desktop controls. Sort of an uber-mix of the MMC console snap-in and the Remote Desktop utility.

One of its cooler features (at least in my mind) is a thumbnail mode. I saw the IE7 tab thumbnail view and just had to have that in my app. The thumbnails make it easy for a single user to monitor many RD sessions. For example, a few weekends ago I used this feature to monitor 40+ machines...

For each active connection I use the PrintWindow API (found via Simon Mourier’s WebLog - TaskSwitch.exe like: PreviewWindow & DevX.com - off-screen capture help) to grab a bitmap each of control and stuff them all into a imagelist/listview. The beauty of the PrintWindow API is that the window (or control, etc) does not have to be openly visibile (i.e. top of the zorder list, etc). So if the window/control is obscured by another, the PrintWindow API will still grab it in full.

Which leads me to today’s story.

Since I built a thumbnail type solution, I’m keyed to watch for ways to improve it. Recently I found a nice method to better scale my bitmaps down to different sizes (my thumbnail sizes are user definable). Coding4Fun - Rob’s Image Shrinker provided cool scaleBitmap method which I adapted for my use. Cool, so now I have nice method to get my thumbnails...

sigh... That was until today. This morning I see the article, DevCity.Net - A Simple Photo Browser. The first thing it talks about is thumbnails. "Nice, I’m always open to new/different/easier ways..." I thought. Quickly browsing the article, I see "bm.GetThumbnailImage".

"No... That’s not built into the .Net ... is it?

Yep. Image.GetThumbnailImage Method, and How to: Create Thumbnail Images

The .Net framework has had this method since 1.0...

Sometimes I just feel so stupid. Here I wasted my time re-inventing the wheel, which is something I really hate doing.

The next feeling I get is that of the thrill of discovery... That today I learned something new, enriching myself and improving my app.

It’s that thrill that keeps me coming back for more.

GOD, I really do love this job! ;)

Technorati Tags: , ,

2 comments:

Anonymous said...

One thing you might run into with GetThumbnail Image: the function only works for generating thumbs under 150x150. anything bigger wont get anti-aliased properly.

Greg said...

Cool... thanks, that's good to know.

So maybe I AM taking the better approach to providing thumbnails...

BTW, I found another thumbnail related article that also talks about GetThumbnailImage and its "issues".

Go Picture Crazy: Resize Images Using GDI+
http://www.devx.com/dotnet/Article/22079/1954?pf=true