Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - More Examples of Simplified Image Processi...
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 
Mobile Linux 
App Generation ROI 
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? 
WINDOWS SCRIPTING

More Examples of Simplified Image Processing in GDI+
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-09-17

    Table of Contents:
  • More Examples of Simplified Image Processing in GDI+
  • Sample Six-Working with Thumbnail Images
  • Sample Seven-Cloning an Image
  • Sample Eight-Zooming in and out

  • 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


    More Examples of Simplified Image Processing in GDI+ - Sample Six-Working with Thumbnail Images


    (Page 2 of 4 )

    In the commonly used picture viewer applications, such as AcdSee, Windows Explorer, a thumbnail gives an outline of a real image. Using GDI+, you can easily achieve the purpose of rendering a thumbnail of an image.

    The following shows the signature of the GetThumbnailImage() method:

    // Summary:

    // Returns a thumbnail for this System.Drawing.Image.

    // Parameters:

    // thumbWidth:

    // The width, in pixels, of the requested thumbnail image.

    // thumbHeight:

    // The height, in pixels, of the requested thumbnail image.

    // callback:

    // A System.Drawing.Image.GetThumbnailImageAbort delegate. In GDI+ version 1.0,

    // the delegate is not used. Even so, you must create a delegate and pass a

    // reference to that delegate in this parameter.

    // callbackData:

    // Must be System.IntPtr.Zero.

    // Returns:

    // An System.Drawing.Image that represents the thumbnail.


    public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData);

    As shown from the above definition, a thumbnail is based upon a whole image; it is in fact only a copy of the original image. In addition, the user can specify the size of a thumbnail of an image-maybe even larger than the original. Next, let us take a close look at a related sample application.

    Graphics graphics=this.CreateGraphics();

    graphics.Clear(Color.White);

    //set up the interpolation mode-HighQualityBicubic

    graphics.InterpolationMode=InterpolationMode.HighQualityBicubic;

    //load the image to be shown as thumbnails

    Bitmap image=new Bitmap("flower.bmp");

    //obtain the size of the current window

    Rectangle client=new Rectangle(0,0,

    this.ClientSize.Width,this.ClientSize.Height);

    float width=image.Width;

    float height=image.Height;

    //get a thumbnail of specified size

    Image.GetThumbnailImageAbort myCallback =

    new Image.GetThumbnailImageAbort(ThumbnailCallback);

    Image pThumbnail = image.GetThumbnailImage(40,40, myCallback ,IntPtr.Zero);

    //use the thumbnail as a brush

    TextureBrush picBrush=new TextureBrush(pThumbnail);

    //fill in the window

    graphics.FillEllipse(picBrush,client);

    Since there are already enough comments in the code, we will not dwell on it. Figure 7 gives the associated running-time snapshot.


    Figure 7-the associated running-time snapshot of the thumbnail effect


    More Windows Scripting Articles
    More By Xianzhong Zhu


     

    WINDOWS SCRIPTING ARTICLES

    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...
    - Modifying XML Files in WSH
    - Reading XML Files in WSH
    - Visual Basic 2005 XML Programming Using XML ...
    - Creating an XML Document in WSH
    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT