/// <Summary>
/// Return the bitmap object based on the specified parameter
/// Reference:
/// Using system. drawing;
/// Call example:
/// Eg1. Save it as an image file
/// Bitmap srbmp = srbitmap (SRS );
/// Srbmp. Save (directory. getcurrentdirectory () + "\ srs.gif", system. Drawing. imaging. imageformat. GIF );
/// Srbmp. Dispose ();
/// Eg2. The webpage is called as follows:
/// Bitmap srbmp = srbitmap (SRS );
/// System. Io. memorystream SRMs = new system. Io. memorystream ();
/// Srbmp. Save (SRMs, system. Drawing. imaging. imageformat. GIF );
/// Response. clearcontent ();
/// Response. contenttype = "image/GIF ";
/// Response. binarywrite (SRMs. toarray ());
/// Srbmp. Dispose ();
/// </Summary>
/// <Param name = "SRS"> </param>
/// <Returns> </returns>
Public static bitmap srbitmap (string SRs)
{
// Define the image Bending Angle
Int srseedangle = 45;
// Define the image
Bitmap srbmp = new Bitmap (SRS. length * 20, 30 );
// Draw
Graphics srgraph = graphics. fromimage (srbmp );
// Clear the image
Srgraph. Clear (color. aliceblue );
// Draw a border for the image
Srgraph. drawrectangle (new pen (color. Black, 0), 0, 0, srbmp. Width-1, srbmp. Height-1 );
// Define the instant count
Random srrandom = new random ();
// Define the paint brush
Pen srpen = new pen (color. lightgray, 0 );
// Draw Noise
For (INT I = 0; I <100; I ++)
{
Srgraph. drawrectangle (srpen, srrandom. Next (1, srbmp. Width-2), srrandom. Next (1, srbmp. Height-2), 1, 1 );
}
// Convert a string into a character array
Char [] srchars = SRS. tochararray ();
// Archive text
Stringformat srformat = new stringformat (stringformatflags. noclip );
// Set the vertical center of Text
Srformat. Alignment = stringalignment. Center;
// Set the text to center horizontally
Srformat. linealignment = stringalignment. Center;
// Define the font color
Color [] srcolors = {
Color. Black, color. Red, color. darkblue, color. Blue, color. Orange, color. Brown, color. darkcyan, color. Purple };
// Define the font
String [] srfonts = {"verdana", "Microsoft sans serif", "Comic Sans MS", "Arial", ""};
// Draw each character cyclically
For (INT I = 0, j = srchars. length; I <j; I ++)
{
// Define the font parameters as the font style, font size, and font shape.
Font srfont = new font (srfonts [srrandom. Next (5)], srrandom. Next (12,20), fontstyle. Regular );
// Fill the image
Brush srbrush = new solidbrush (srcolors [srrandom. Next (7)]);
// Define coordinates
Point srpoint = new point (16, 16 );
// Define the skew angle
Float srangle = srrandom. Next (-srseedangle, srseedangle );
// Skew
Srgraph. translatetransform (srpoint. X, srpoint. y );
Srgraph. rotatetransform (srangle );
// Fill in characters
Srgraph. drawstring (srchars [I]. tostring (), srfont, srbrush, 1, 1, srformat );
// Return to normal
Srgraph. rotatetransform (-srangle );
Srgraph. translatetransform (2,-srpoint. y );
}
Srgraph. Dispose ();
Return srbmp;
}