欢迎光临
我们一直在努力

画带阴影效果的文字-.NET教程,评论及其它

建站超值云服务器,限时71元/月

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;

namespace windowsapplication1

{

/// <summary>

/// form1.的摘要说明。

/// </summary>

public class form1 : system.windows.forms.form

{

/// <summary>

/// 必需的设计器变量。

/// </summary>

private system.componentmodel.container components = null;

private string texttodraw = "【孟宪会之精彩世界】";

public form1()

{

//

// windows 窗体设计器支持所必需的

//

initializecomponent();

// 在 initializecomponent 调用后添加任何构造函数代码

this.setstyle(controlstyles.resizeredraw,true);

}

/// <summary>

/// 清理所有正在使用的资源。

/// </summary>

protected override void dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.dispose();

}

}

base.dispose( disposing );

}

#region windows form designer generated code

/// <summary>

/// 设计器支持所需的方法 – 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void initializecomponent()

{

//

// 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);

}

#endregion

/// <summary>

/// 应用程序入口点

/// </summary>

[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.forms.painteventargs e)

{

// 创建一个小的bitmap

bitmap bm = new bitmap(this.clientsize.width/4,this.clientsize.height/4);

//得到 graphics 对象

graphics g = graphics.fromimage(bm);

// 必须使用 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;

// 画阴影

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();

}

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 画带阴影效果的文字-.NET教程,评论及其它
分享到: 更多 (0)

相关推荐

  • 暂无文章