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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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: 5 stars5 stars5 stars5 stars5 stars / 1
    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

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek