string shape =
Request.QueryString["shape"].ToString();
//
create a large enough canvas, and it must be 32bppArgb, which supports
transparency
Bitmap canvas = new Bitmap(640, 480,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(canvas);
//
make the canvas transparent
g.Clear(Color.Transparent);
g.Dispose();
IC.CoolWatermark.Writer cw = new Writer(canvas);
IC.CoolWatermark.Shape textShape;
//
setup the textShape
switch (shape)
{
case "Dither":
{
textShape = new Shape( ShapeStyle.Dither
);
break;
}
case "RainbowUpper":
{
textShape = new Shape(ShapeStyle.RainbowUpper);
break;
}
case "RainbowLower":
{
textShape = new Shape(ShapeStyle.RainbowLower);
break;
}
default: // otherwise
just use Bulge if the querystring
{
textShape = new Shape(ShapeStyle.Bulge);
break;
}
} // end switch
cw.Shape =
textShape;
cw.PositionStyle =
PositionStyle.MiddleCenter;
cw.FontSize = 48;
cw.FontStyle = FontStyle.Bold;
cw.FontFamily = new FontFamily("Impact");
cw.Spacing = 0;
cw.Colors = new Color[] { Color.Red };
cw.WriteText(text);
// create
a new bitmap to store the text bitmap
Bitmap textBitmap = new Bitmap(cw.BoundedSize.Width,
cw.BoundedSize.Height, PixelFormat.Format32bppArgb);
g = Graphics.FromImage(textBitmap);
g.Clear(Color.Transparent);
// cut
the text portion to the textBitmap
g.DrawImage(cw.Image,
0, 0, cw.BoundedArea, GraphicsUnit.Pixel);
g.Dispose();
// we
don't need canvas now
canvas.Dispose();
//
release this first, and we will need a new one
cw.Dispose();
//
let's marble the textBitmap first
IC.PhotoController.Controller pc = new
IC.PhotoController.Controller(textBitmap);
//
setup the marble filter
MarbleFilter filter = new MarbleFilter();
filter.Turbulence
= 1;
filter.Movement =
3;
filter.Level = 10;
Bitmap final = new Bitmap(pc.Filter(filter));
pc.Dispose();
//
this is the final step, we output the embossed text to the sample image
cw = new Writer(sample);
cw.PositionStyle =
PositionStyle.MiddleCenter;
Bitmap result = new Bitmap(
cw.WriteImage(final) );
//
output to page
MemoryStream oStream = new MemoryStream();
result.Save(oStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
Response.BinaryWrite(oStream.ToArray());
//
release resources
cw.Dispose();
result.Dispose();
final.Dispose();