Writing with shadow effect

zhaozj2021-02-12  141

using System; using System.Drawing; using System.Drawing.Text; using System.Drawing.Drawing2D; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;

Summary description of Namespace WindowsApplication1 {///

/// form1. /// public class form1: system.windows.Forms.form {/// // The designer variable is required. ///

Private system.componentmodel.container components = null; private string texttodraw = "The Wonderful World of Mengxian]

Public Form1 () {// // Windows Form Designer Support for

InitializationComponent ();

// Add any constructor code after INITIALIZECOMPONENT call

THIS.SETSTYLE (ControlStyles.ResizeRedRAW, TRUE);

}

///

/// Clean all the resources being used. ///

Protected Override Void Dispose (bool disposing) {if (disponents! = null) {components.dispose ();}} Base.Dispose (Disposing);

#Region Windows Form Designer Generated Code ///

/// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// private () {/// Form1 // this.autoscalebasesize = new system.drawing.size (16, 36); this.backcolor = system.drawing.color.white; this. Clientsize = new system.drawing.size (376, 293); this.font = new system.drawing.font ("tahoma", 21.75f, system.drawing.fontstyle.bold, system.drawing.graphicsUnit.point, ((( System.byte) (0))); this.name = "form1"; this.text = "form1"; this.paint = new system.windows.forms.painteventhandler (this.form1_paint);

}

#ndregion

///

/// application entry point ///

[Stathread] static void main () {application.run (new form1 ());}

protected override void OnPaintBackground (PaintEventArgs e) {LinearGradientBrush b = new LinearGradientBrush (this.ClientRectangle, Color.Blue, Color.AliceBlue, 90f); e.Graphics.FillRectangle (b, this.ClientRectangle); b.Dispose ();} Private void form1_paint (Object sender, system.windows) {// Create a small Bitmap Bitmap BM = New Bitmap (this.clientsize.width / 4, this.clientsize.height / 4);

// Get Graphics object graphics g = graphics.FromImage (BM);

/ / Must use antialiased rendering hint g.textrenderinghint = textrenderingHint.antialias;

// this Matrix Zooms The Text Out to 1/4 Size and Offsets It by a little Right and Down

Matrix MX = New Matrix (0.25F, 0, 0, 0.25F, 3, 3);

g.Transform = MX;

// Draw a shadow

g.DrawString (TextToDraw, Font, new SolidBrush (Color.FromArgb (128, Color.Black)), 10, 10, StringFormat.GenericTypographic); g.Dispose (); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e. Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; e.Graphics.DrawImage (bm, this.ClientRectangle, 0,0, bm.Width, bm.Height, GraphicsUnit.Pixel); e.Graphics.DrawString (TextToDraw, Font, Brushes.White , 10, 10, stringformat.GenericTyPographic; bm.dispose ();}}}

转载请注明原文地址:https://www.9cbs.com/read-6891.html

New Post(0)