imageComponent.NET title a curve
   Home Page | Blog | Online Forum | Links | SiteMap
Skip Navigation Links.
- Recommended .NET Book -

Programming Microsoft ADO.NET 2.0 Applications: Advanced Topics (Paperback)

Book Description Get in-depth coverage and expert insights on advanced ADO.NET programming topics s...[more]
Skip Navigation LinksHome > Products > PhotoController > Demo for v2.x

Overview

This page demonstrates only some new filters in PhotoController v2.x. It is strongly recommended to download the demo application to try all of them. The full source code is available for you.

Notes: Tow choices (OilFilter and ZoomBlurFilter) are added, but the sample code on this page is not updated.

Image Filters

Choose the filter in the dropdown list and click [Apply] button, you will see the below image processed by the specified filter.

   

Original Test Image



Source Code

The following C# source shows the code behinde of this demonstration. The code is to read the selected filter's name from querystring and apply the filter to PhotoControll assembly. After processing the image, write it to the page.


string filter = Request.QueryString["filter"].ToString();

 

Bitmap bm = new Bitmap(sample); // the original bitmap

Bitmap bitmap; // the result bitmap

Controller pc = new Controller(bm);

 

switch (filter)

{

case "Marble":

{

MarbleFilter marbleFilter = new MarbleFilter();

marbleFilter.Edge = EdgeType.Clamp;

marbleFilter.Level = 5;

marbleFilter.Movement = 5;

marbleFilter.Turbulence = 1;

 

bitmap = new Bitmap(pc.Filter(marbleFilter));

break;

}

case "Shake":

{

ShakeFilter shakeFilter = new ShakeFilter();

shakeFilter.Edge = EdgeType.Clamp;

shakeFilter.Level = 10;

 

bitmap = new Bitmap(pc.Filter(shakeFilter));

break;

}

case "Sphere":

{

SphereFilter sphereFilter = new SphereFilter();

// CenterX and CenterY are percentage of the width and height

sphereFilter.CenterX = 50;

sphereFilter.CenterY = 50;

sphereFilter.Edge = EdgeType.Clamp;

sphereFilter.Radius = 250;

sphereFilter.Zoom = 5;

 

bitmap = new Bitmap(pc.Filter(sphereFilter));

break;

}

case "Twirl":

{

TwirlFilter twirlFilter = new TwirlFilter();

twirlFilter.CenterX = 50;

twirlFilter.CenterY = 50;

twirlFilter.Edge = EdgeType.Wrap;

twirlFilter.Angle = 5;

twirlFilter.Radius = 200;

 

bitmap = new Bitmap(pc.Filter(twirlFilter));

break;

}

case "HSL":

{

Random rand = new Random();

 

//only change Hue in this demonstration

float hue = rand.Next(180);

                       

HSLAdjustFilter hslFilter = new HSLAdjustFilter();

 

// the range of Hue is -180.0 to 180.0

hslFilter.Hue = hue - 180.0f;

// the range of Saturation is -1.0 to 1.0

hslFilter.Saturation = 0 ;

// the same to lightness

hslFilter.Lightness = 0;

 

bitmap = new Bitmap(pc.Filter(hslFilter));

break;

}

case "Solarize":

{

SolarizeFilter solarizeFilter = new SolarizeFilter();

solarizeFilter.Level = 100;

 

bitmap = new Bitmap(pc.Filter(solarizeFilter));

break;

}

default:

{

// querystring error, copy the original image

bitmap = new Bitmap(bm);

break;

}

}

 

// release photocontroller

pc.Dispose();

 

MemoryStream oStream = new MemoryStream();

bitmap.Save(oStream, System.Drawing.Imaging.ImageFormat.Jpeg);

Response.BinaryWrite(oStream.ToArray());

 

bm.Dispose();

bitmap.Dispose();

Response.End();

 




  Quick Search
Components
Books



Sponsors

  Home | Links | Blog | SiteMap | About | 2005-2007 © imageComponent.NET, All Rights Reserved.