Knowledge Base > Frame Effect by using Feather
PhotoController 2.1
ContentsIndexHome
PreviousUpNext
Frame Image in .NET

The Feather feature can be used in a creative way. With it, you can generate a good-looking frame. The following figure demonstrates the result of it.

To apply the above "frame" to your image, open the demo application, load an image, select menu - [Filter]->[Feather]-> [Frame with a Feather Way]. Then you will see.

Notes: The code hard code to load the BackgroundTexture1.bmp, which is under the same folder with the demo executable program file. So, if the file is not there, an exception will be thrown out.

Next is the source code of the above operation. Actually, the process is straightforward:

  1. Initialize a FeatherBuilder object.
  2. Specify to use Bitmap for feather background
  3. Load a tile bitmap for FeatherBuilder object.
  4. Specify the Band value.
  5. Build a mask to the Image by calling any BuildXXXMask method.
    After this step, your feather has been built. If you want a border to enhance the frame feeling, you will need to call SetBorder method to do so.

Controller pc = new Controller(pic.Image);

FeatherBuilder builder = new FeatherBuilder(pic.Image.Width, pic.Image.Height);

 

// tell builder to use bitmap as background

builder.BackgroundStyle = FeatherBackgroundStyle.UseBitmap;

 

string currentfolder = Path.GetDirectoryName(Application.ExecutablePath);

builder.LoadTileBitmap(currentfolder + "\\BackgroundTexture1.bmp");

 

// IMPORATNT

// set band to be a small value.

// if you set this too large, the picture will be feathered too much

builder.Band = 2;

 

// create a rectangle that is 25 smaller than picture

// the width 25 will be replaced by tile bitmap

Rectangle rect = new Rectangle(25, 25, pic.Image.Width - 50, pic.Image.Height - 50);

builder.BuildRectangleMask(rect);

 

// this border style might not be similar to a frame shadow, you could try others

BorderBuilder borderBuilder = new BorderBuilder();

borderBuilder.Brush = new SolidBrush(Color.Gray);

borderBuilder.Length = 27;

 

// because the feather background will occupy 25 width, the border width here must be larger than 25 so that

// it could be seen and have a frame feeling

// write border firstly to have a shadow feeling

pc.SetBorder(borderBuilder);

 

// after writing a border, then feather myself to have a similar frame feeling

pic.Image = pc.Feather(builder);



Send comments about this topic.
Copyright (c) 2006-2007 @ ImageComponent.NET All rights reserved.