imageComponent.NET - image processing .NET assemblies
Online Demo - Shape and Effect

This page demonstrates the source code of a simple program by using CoolWatermark. Due to the constraint of my new web host provider, I am no longer able to provide a live demo. But feel free to download all the demo and their source code.

The following sample code takes a parameter and apply shape and effect to the watermark text:

1: ShapeStyle shape;
2: try
3: {
4:     shape = (ShapeStyle)int.Parse(Request.QueryString["shape"]);
5: }
6: catch
7: {
8:     shape = ShapeStyle.Default;
9: }
10:  
11: EffectStyle effect;
12:  
13: try
14: {
15:     effect = (EffectStyle)int.Parse(Request.QueryString["effect"]);
16: }
17: catch
18: {
19:     effect = EffectStyle.Default;
20: }
21:  
22: Shape sp = new Shape();
23: sp.ShapeStyle = shape;
24: switch (shape)
25: {
26:     case ShapeStyle.ShearHorizontal:
27:     case ShapeStyle.ShearVertical:
28:     case ShapeStyle.SwellHorizontal:
29:     case ShapeStyle.SwellVertical:
30:     case ShapeStyle.RainbowLower:
31:     case ShapeStyle.RainbowUpper:
32:         sp.Degree = 50;
33:         break;
34:     case ShapeStyle.Squeeze:
35:     case ShapeStyle.ArchLower:
36:     case ShapeStyle.ArchUpper:
37:     case ShapeStyle.Bulge:
38:         sp.Degree = 200;
39:         break;
40:     case ShapeStyle.Dither :
41:         sp.Degree = 3;
42:         break;
43:     case ShapeStyle.RipTop:
44:     case ShapeStyle.RipBottom:
45:         sp.Degree = 10;
46:         break;
47:     default:
48:         sp.Degree = 20;
49:         break;
50: }
51:  
52: Effect et = new Effect();
53: et.EffectStyle = effect;
54: et.Distance = 5;
55:  
56: Writer writer = new Writer(canvas);
57:  
58: //writer.Colors = new Color[] {Color.White,
                Color.Orange };
59: writer.Effect = et;
60: writer.Shape = sp;
61: writer.PositionStyle = PositionStyle.BottomRight;
62: writer.FontFamily = new FontFamily("Arial");
63: writer.FontSize = 28;
64: System.Drawing.Image result = writer.WriteText("ImageComponent.NET");
65: MemoryStream oStream = new MemoryStream();
66: result.Save(oStream, System.Drawing.Imaging.ImageFormat.Jpeg);
67: Response.BinaryWrite(oStream.ToArray());

The source is pretty straight-forward. I read the query string parameters and create the Shape and Effect accordingly. Then assign to the writer. (Sorry the source code in this demo is written in C#, please let me know if you are seeking VB.NET version)

[Back to Top]
Comments

If you feel this page can be improved or has any mistake, please enter your valuable opinion here. Or if you cannot find the information you are after, feel free to suggest a subject too. I appreciate any voice.

Your Name:
  
Your Email Address:
  
Comments: