国产探花免费观看_亚洲丰满少妇自慰呻吟_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);

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平邑县| 石棉县| 左权县| 台南市| 青冈县| 舒兰市| 永嘉县| 崇仁县| 正宁县| 达孜县| 阿荣旗| SHOW| 余庆县| 万载县| 东源县| 石阡县| 开封市| 沂南县| 平乐县| 慈溪市| 和林格尔县| 新蔡县| 措勤县| 潮州市| 扎鲁特旗| 合水县| 独山县| 通榆县| 河津市| 嘉禾县| 新宾| 托克逊县| 梓潼县| 乌什县| 鞍山市| 云梦县| 阳高县| 花垣县| 红河县| 怀化市| 吉林市|