By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

How do I create a fast/low memory usage thumbnail control on WinForms?

P: 1
Hi guys,
I've tried to create an user control that contains a picture box and have also created a similar control that paints an image inside a panel control with a border to make it look like a thumbnail, on both approaches it seems to use a lot of ram memory to keep that image displayed on the thumbnail and scrolling through many thumbnails can suck up some cpu time, what is the fastest approach to create several controls, thumbnail like inside a master panel that won't use so much memory and cpu?
Thanks!
Feb 27 '09 #1
Share this Question
Share on Google+
3 Replies


tlhintoq
Expert 2.5K+
P: 3,525
... To make it look like a thumbnail ...
It sounds like you aren't actually making a thumbnail, but rather loading the full size image and having Windows display it scaled down. The problem with this is exactly what you have seen: The object in memory is the full size image. If you are using a typical 10mp camera you are going to go out of memory really fast.

There are some built in GetThumbnail routines available to you from the .NET framework. Or you can read in the fullsize image, and scale it yourself into a new bitmap object, then dispose of the fullsize object and place the scaled image in your PictureBox. Personally this is what I do. My scaling methods have a few more arguments so I can choose to preserve the full color-depth or not, add a border or not, scale to max width or max height etc.

But for starters use the built in functions to see if that solves your issues and is of sufficient quality to save you the work in writting your own scaling.

TIP. The .NET method for GetImage.FromFile(string FilePath) has a glitch that keeps the file on hard drive locked up as long as you are using it. So if you use this method load to a TemporaryImage the copy that into a FinalImage then .Dispose() of TemporaryImage so your application is still tied to the harddrive file keeping any other program from having access to it.
Feb 28 '09 #2

kunal pawar
100+
P: 297
U can use Bitmap class to get thumbail of image.

Bitmap b = new Bitmap(fileName);

Image img = b.GetThumbailImage(...);

b.dispose();
Mar 2 '09 #3

tlhintoq
Expert 2.5K+
P: 3,525
@kunal pawar
I'm a huge beleiver in learning through doing and experimenting.
So... Can you? When you try to do this does it work? What does Visual Studio tell you when you try to run this?
Mar 2 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.