473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
3 4348
tlhintoq
3,525 Expert 2GB
... 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
297 100+
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
3,525 Expert 2GB
@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

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

Similar topics

6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
0
by: Balu Ramachandran | last post by:
How can I create the Thumbnail view from the form? In the following approach I tried but Iams facing some limitations to get the thumbnail image of the form alone. Plaese any one can help in...
2
by: Mark R. Dawson | last post by:
Hi all, I have a directory full of images (most over 2MB in size) I was to show each image as a thumbnail on a form, however in order to create a thumbnail I have to open the complete image then...
3
by: bamapookie | last post by:
I am new to VB, but not new to programming. I am using VB.Net 2003 and I have written a small app to monitor several running processes and everything is fine except the memory usage. When the app...
6
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
34
by: Tom | last post by:
I'd greatly appreciate advice and code snippets on how to create a ram disk within a C/C++ program. I also need to be able to determine the free space. Thanks in advance for any help.
3
by: pedrito | last post by:
I've got an app that downloads images off the internet using anywhere from 1-20 threads concurrently (though generally around 4 threads). I have a preview page that shows the images as they're...
9
by: deerchao | last post by:
I'm developing a WinForms application. It slowly eats up memory, one client reported that it took 200MB or more, and finnaly crashed. I myself noticed it's common to use up 30MB memory, but if I...
17
by: Cesar | last post by:
Hello people. I'm having a Winform app that contains a webbrowser control that keeps navigating from one page to another permanentrly to make some tests. The problem I'm having is that after a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.