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

Developing Microsoft .NET Controls with Microsoft Visual Basic .NET

From Book News, Inc. Written for experienced developers, this guide explains how to work wit...[more]
Skip Navigation LinksHome > Products > CoolWatermark > Demo

Overview

This page demonstrates some standard features in CoolWatermark v1.x. With its flexible functions, you can easily implement more fancy and powerful effects.

Registration Validation

This application demonstrates a registration page with verification code. Normally, during the registration, the webpage will display an image with a random number. The user must verify the number to complete the registration. It will prevent attacks from some registration programs. In here, I just show how to generate such an image with a random number with CoolWatermark.



[Reload]    [View Code]

Customize Text

This application demonstrates writing customized watermark. Enter any text in the text field, and choose your preference. Click [Submit] button to see the result.
Text
FontFamily
Size
ShapeStyle
FilterStyle
TextColor





Source Code

The following C# source code shows the code-behind of the validation part.

// Define the page content type
Response.ContentType = "image/jpeg";

Bitmap bitmap;
Graphics g;

// initialize the blank bitmap

bitmap = new Bitmap(240,48);
g = Graphics.FromImage(bitmap);
HatchBrush hb = new HatchBrush(HatchStyle.DottedGrid,Color.Black,Color.White);
g.FillRectangle(hb,0,0,240,48);

// generate a random number
int num=0;
Random rand = new Random();
while (num<10000)
{
num = rand.Next(99999);
}

// initialize the CoolWatermark writer and assign the properties
angGoGo.CoolWatermark.Writer writer = new Writer((System.Drawing.Image)bitmap);
writer.PositionStyle = PositionStyle.MiddleCenter;
writer.Shadow = new Shadow(Color.LightGray,3,3);
writer.FontStyle = FontStyle.Bold;
writer.FontSize = 32;
writer.FontFamily = new FontFamily("Arial");
writer.Colors = new Color[]{Color.White};
writer.Border = new Border(Pens.Black);
bitmap = new Bitmap(writer.WriteText(num.ToString()));
writer.Dispose();

// write to webpage
MemoryStream oStream = new MemoryStream();
bitmap.Save(oStream,System.Drawing.Imaging.ImageFormat.Jpeg);
Response.BinaryWrite(oStream.ToArray());
bitmap.Dispose();
g.Dispose();
Response.End();



  Quick Search
Components
Books



Sponsors

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