Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - Simplified Image Processing in GDI+
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

Simplified Image Processing in GDI+
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0
    2008-09-10

    Table of Contents:
  • Simplified Image Processing in GDI+
  • Meta File Support in GDI
  • Sample One-Record and Replay Metafiles
  • Sample Two-Clipping and Scaling Images
  • Sample Three-Use Interpolation to Output
  • Sample Four-Flipping an Image

  • 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


    Simplified Image Processing in GDI+ - Sample Two-Clipping and Scaling Images


    (Page 4 of 6 )

    Now, let us shift our attention to another application of the image process supported by GDI+-clipping and scaling images. There is still nothing peculiar here; all functions still rest on the DrawImage() method. As usual, let us first look at the running-time snapshot, as is shown in Figure 2.


    Figure 2-the running-time snapshot for sample 2

    The following gives the short coding in this sample:

    Graphics graphics=this.CreateGraphics();

    graphics.Clear(Color.White);


    //load the image

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

    int width = image.Width;

    int height = image.Height;


    //enlarge the target area by 1.4 times of the source image

    RectangleF destinationRect=new RectangleF(

    width+10, 0.0f, 1.4f* width, 1.4f* height);

    //first render the source image

    graphics.DrawImage(image, 0, 0);


    //then draw the bitmap onto the target area

    graphics.DrawImage(

    image,

    destinationRect,

    new RectangleF(0, 0, //upper left corner of the source image

    0.65f*width, // only render 65% of the width of the source image

    0.65f * height), // only render 65% of the height of the source image

    GraphicsUnit.Pixel);

    Here, we first enlarge the target area 1.4 times and then in the DrawImage() function we shrink the rendering area to 65% of the original image, by which both the clipping and scaling effects are achieved. As is shown is Figure 2, you may find the body of the goldfish becomes bigger, while the mouth of the goldfish is still invisible, which is just the effect accomplished by clipping and scaling. In addition, you will find that in the enlarged image appears some blurring effect, which will be covered in the next topic.

    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 1 hosted by Hostway
    Stay green...Green IT