![]() |
Multimedia »
GDI+ »
General
Intermediate
Thumbnail Generator - An easy way to process thumbnails from a large amount of imagesBy Christian BallerstallerThumbnail Generator application supporting a bunch of image file types (for both: source images and target thumbnails), fixed target image size as well as ratio calculation, and full internationalization. |
C#.NET 1.0, Win2K, WinXP, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
![]()
I have always had problems generating thumbnails from a large amount of images quickly and easily. Also standard graphic programs couldn't meet my needs - or it simply took too much time handling image after image.
This Thumbnail Generator is qualified for generating thumbnails of images you are publishing on the Internet. Pre-generated thumbnails save you processor utilization and disk space (if you're generating thumbnails on the fly) - or user's time and money.
But also converting a large amount of images from one file format to another can be handled easily.
This project might also be an interesting starting point for Win Form rookies. Learn how forms, simple internationalization support and XML are working together! Just download the project source code, all source files are commented.
Generating a ListBox item:
/* Retrieve image to get it's infos */
Image LbxSourceImage = Image.FromFile(filesFromDialog[i]);
imgList.Images.Add(LbxSourceImage);
/* Calculate image ratio */
float Ratio=((float)LbxSourceImage.Width)/((float)LbxSourceImage.Height);
/* Generates Listboxitem */
ImageListBoxItem lbxItem = new ImageListBoxItem(
filesFromDialog[i].ToString()+ /* Filename */
"\r\n"+txtWidth+LbxSourceImage.Width.ToString()+ /* Width */
", "+txtHeight+LbxSourceImage.Height.ToString()+ /* Height */
", "+txtRatio+Ratio.ToString(),i); /* Ratio */
lbxSource.Items.Add(lbxItem);
Also full multilingual support for English and German language is provided. (Feel free to contribute other translations ;) )
Internationalization is managed via XML. All GUI texts are read on startup, from the application configuration file (of course the language can also be changed during a session). The project includes a collection of useful methods for processing XML documents. You can easily use them for your own applications.
The configuration file looks like:
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE Application SYSTEM "Config.dtd">
<Application>
<Information>
<Name>Thumbnail Generator</Name>
<Version>0.8</Version>
</Information>
<StdLanguage Type="en"/>
<Language Type="en">
<Text GUIRelation="btnGenerateThumb">Generate Thumbnails -->
Within the application the language information is fetched via XPath. Sample calls:
XPathDocument XPathDoc = new XPathDocument(configFileName);
XPathNavigator nav = XPathDoc.CreateNavigator();
gbxSource.Text = XmlManager.GetValueFromXPath(nav,
"/Application/Language[@Type='"+
CurrentLang+"']/Text[@GUIRelation='gbxSource']");
gbxTarget.Text = XmlManager.GetValueFromXPath(nav,
"/Application/Language[@Type='"+
CurrentLang+"']/Text[@GUIRelation='gbxTarget']");
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 9 Mar 2003 Editor: Smitha Vijayan |
Copyright 2003 by Christian Ballerstaller Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |