Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - 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 Seven-Cloning an Image


    (Page 3 of 4 )

    Clone, i.e. "copy," is a new concept introduced in GDI+. You can wholly or partially clone a picture, which is performed by the Clone() method of the Bitmap class (or other classes, such as Image). To perform a partial cloning, you have to specify the related local coordinates.

    The clone function of a picture is very important in scenarios requiring special image effects. Take for example, if you want to render an image by mosaic at random, the local operation becomes of great importance. Similarly, under conditions that require rendering an image piece by piece with delay, it also needs partial image handling.

    In this sample, we achieve the effect of splitting a big image into four equal pieces, then clone them, and finally render them sequentially. Now let us look at the related code, as follows:

    private void Clone_Click(object sender, System.EventArgs e)

    {

    Graphics graphics=this.CreateGraphics();

    graphics.Clear(Color.White);


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

    int Height=image.Height;

    int Width=image.Width;


    // define the four areas that are used to divide a picture

    RectangleF[] block=new RectangleF[4];

    block[0]=new Rectangle(0,0,Width/2,Height/2);

    block[1]=new Rectangle(Width/2,0,Width/2,Height/2);

    block[2]=new Rectangle(0,Height/2,Width/2,Height/2);

    block[3]=new Rectangle(Width/2,Height/2,Width/2,Height/2);


    // close the four parts of an image respectively

    Bitmap[] s=new Bitmap[4];

    s[0]=image.Clone(block[0],PixelFormat.DontCare);

    s[1]=image.Clone(block[1],PixelFormat.DontCare);

    s[2]=image.Clone(block[2],PixelFormat.DontCare);

    s[3]=image.Clone(block[3],PixelFormat.DontCare);

    // render the four parts of the given image in turn the rendering time span is 1 second

    graphics.DrawImage(s[0],0,0);


    // delay to achieve the effect of rendering block by block

    Thread.Sleep(1000);

    graphics.DrawImage(s[1],Width/2,0);

    Thread.Sleep(1000);

    graphics.DrawImage(s[3],Width/2,Height/2);

    Thread.Sleep(1000);

    graphics.DrawImage(s[2],0,Height/2);

    }

    Running the above code, you will get a snapshot illustrated in Figure 8.


    Figure 8-the running-time snapshot of cloning four parts of an image respectively

    Note that although Figure 8 shows an integrated image, it is composed of four equal small scraps which are rendered every second.

    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