Browse DevX
Sign up for e-mail newsletters from DevX


Generate and Modify Images with GDI+  : Page 4

Use GDI+ and the System.Drawing classes to simplify the process of manipulating images.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Creating Thumbnail Images
You can use a similar technique to create a true thumbnail of your image. The Image class supports a GetThumbnailImage method which generates thumbnails. For example:

const string cstrThumbFileName = "\\Thumb_Sample.gif"; System.Drawing.Image img = System.Drawing.Image.FromFile (strFileName); System.Drawing.Image.GetThumbnailImageAbort imgCallBack = new System.Drawing.Image.GetThumbnailImageAbort (CallBackMethod); System.Drawing.Image imgThumbnail = img.GetThumbnailImage(img.Width/4, img.Height/4, imgCallBack, IntPtr.Zero); imgThumbnail.Save (Application.StartupPath + cstrThumbFileName);

Calling the GetThumbnailImage method and passing in the width and height of the thumbnail, along with an Image.GetThumbnailImageAbort delegate and IntPtr.Zero creates a new instance of the Image object that represents the thumbnail of your original image.

Author Note: The Image.GetThumbnailImageAbort delegate and IntPtr.Zero parameters are required even though they support a callback that is not yet used in GDI+ 1.0.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date