C#
  Home arrow C# arrow Page 3 - Thumbnails and Zooming with GDI+ and C#
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Thumbnails and Zooming with GDI+ and C#
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2006-10-31

    Table of Contents:
  • Thumbnails and Zooming with GDI+ and C#
  • Image Manipulation: Thumbnail, Zooming and Saving
  • Image Manipulation in the Real World
  • Image Manipulation in the Real World, continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Thumbnails and Zooming with GDI+ and C# - Image Manipulation in the Real World


    (Page 3 of 4 )

    It is time to put the theory into practice. I will do this by enhancing the application developed in the last part by adding the following functionalities:

    1. Save the image in the format specified by user.
    2. Zoom in according to the percentage selected from the menu.
    3. Create a thumbnail of a loaded image.

    The menus corresponding to the operations are:

    • mnuSave – the submenu of File menu to save the image.
    • mnu200Zoom – zooms the image by 200%.
    • mnuThumbNail- creates a thumbnail of the image.

    Here is the method that handles the click event of mnuSave:

    private void mnuSave_Click(object sender,     System.EventArgs e) { // If image is created     if(curImage == null)         return;     // Call SaveFileDialog     SaveFileDialog saveDlg = new SaveFileDialog();     saveDlg.Title = "Save Image As";     saveDlg.OverwritePrompt = true;     saveDlg.CheckPathExists = true;     saveDlg.Filter =         "Bitmap File(*.bmp)|*.bmp|" +         "Gif File(*.gif)|*.gif|" +         "JPEG File(*.jpg)|*.jpg|" +         "PNG File(*.png)|*.png" ;     saveDlg.ShowHelp = true;     // If selected, save     if(saveDlg.ShowDialog() == DialogResult.OK)     {         // Get the user-selected file name         string fileName = saveDlg.FileName;         // Get the extension         string strFilExtn =             fileName.Remove(0, fileName.Length - 3);         // Save file         switch(strFilExtn)         {            case "bmp":                 curImage.Save(fileName, ImageFormat.Bmp);                 break;             case "jpg":                 curImage.Save(fileName, ImageFormat.Jpeg);                 break;             case "gif":                 curImage.Save(fileName, ImageFormat.Gif);                 break;             case "tif":                 curImage.Save(fileName, ImageFormat.Tiff);                 break;             case "png":                 curImage.Save(fileName, ImageFormat.Png);                 break;             default:                 break;             }     } }

    First the save dialog box is shown with acceptable extensions. Then, from the file name returned by the dialog box, the extension is retrieved. Finally, according to the extension, the Save() method is called with the corresponding image format parameter.

    More C# Articles
    More By A.P.Rajshekhar


       · In the second part of the series I have discussed about the working of GDI+ as well...
     

    C# ARTICLES

    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...
    - Color Transformation in C# GDI+ Programming
    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway