国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#中關于GDI+輸出的問題

2024-07-21 02:17:50
字體:
來源:轉載
供稿:網友
中國最大的web開發資源網站及技術社區,

在.net framework的框架中有很多操作各種圖形的函數,包括:點,線,面等等,構成的各種各樣的豐富的圖象。

在這里我主要是介紹在.net framework中gdi+下的text(文本)的操作。首先以一個小小的程序開始:

   建立一個windows應用程序

   在窗體上添加一個button控件 和 一個picturebox控件.    在button控件的事件中添加,如下代碼:

 

 sizef textsize ;//定義一個sizef的變量,而sizef的描述:

//存儲有序浮點數對,通常為矩形的寬度和高度。

graphics g;

brush mybrush ;//定義一個刷子。

 font myfont = new font("times new roman", 80, fontstyle.bold);

//定義要輸出字體的樣式和大小

g = picturebox1.creategraphics();//creategraphics 方法

也可以使用某控件或窗體的 creategraphics 方法來獲取對 graphics 對象的引用,該對象表示該控件或窗體的繪圖表面

g.clear(color.white);// 清除整個繪圖面并以指定背景色填充。

string str = "kevin";//要輸出的文本

textsize = g.measurestring(str,myfont);// 測量用指定的 font 對象繪制的指定字符串。

mybrush=new hatchbrush(hatchstyle.dashedupwarddiagonal,color.blue,color.white);

//這里使用的是hatchbrush畫刷。

g.drawstring(str,myfont,mybrush,(picturebox1.width/4),(picturebox1.height/2)); //輸出文本

當然如果將上述代碼在變一下的話。就是另外一番風景啊~~

sizef textsize ;

graphics g;

brush mybrush;

single xlocation,ylocation;

matrix mymatrix;

font myfont = new font("times new roman", 80, fontstyle.bold);

g = picturebox1.creategraphics();

g.clear(color.white);

string str = "kevin";

textsize = g.measurestring(str,myfont);

xlocation = (picturebox1.width/4)-5;

ylocation =(picturebox1.height/2-5);

g.translatetransform(xlocation,ylocation);

mymatrix = g.transform;

mymatrix.shear(1,0);

g.transform = mymatrix;

mybrush=new hatchbrush(hatchstyle.dashedupwarddiagonal,color.blue,color.white); g.drawstring(str,myfont,mybrush,0,0);

sizef textsize ;

graphics g;

brush mybrush = brushes.blue;

brush backbrush= brushes.gray;

single xlocation,ylocation;

font myfont = new font("times new roman", 80, fontstyle.bold);

g = picturebox1.creategraphics();

g.clear(color.white);

string str = "kevin";

textsize = g.measurestring(str,myfont);

xlocation = (picturebox1.width/4)-5;

ylocation =(picturebox1.height/2-5);

g.drawstring(str,myfont,backbrush,(picturebox1.width/4),(picturebox1.height/2)); g.drawstring(str,myfont,mybrush,xlocation,ylocation);

這就是我想給各位的一個非常簡單的操作文本程序。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南开区| 绿春县| 都匀市| 百色市| 寿阳县| 黑龙江省| 威海市| 利津县| 台安县| 景宁| 钦州市| 徐州市| 新化县| 扶绥县| 寿光市| 辽中县| 绩溪县| 铁岭市| 达日县| 松江区| 孟村| 普洱| 凉城县| 潍坊市| 胶南市| 九龙城区| 分宜县| 鹤壁市| 泗洪县| 内丘县| 澳门| 行唐县| 洛阳市| 河间市| 湖南省| 柳州市| 松原市| 沅陵县| 翁源县| 禄丰县| 女性|