日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

【STM32 .Net MF開(kāi)發(fā)板學(xué)習(xí)-03】TinyGUI繪圖示例

系統(tǒng) 1859 0

【低價(jià)開(kāi)發(fā)板】 http://item.taobao.com/item.htm?id=7117999726

.Net Micro Framework 官方圖形庫(kù)是 WPF ,由于目前 ST Cortex-M3 開(kāi)發(fā)板 RAM 太小,最大才 512K (常見(jiàn)是 128K 256k ),并且 Cortex-M3 CPU 主頻也不太高,運(yùn)行 WPF 圖形框架顯得過(guò)于重了,所以我這邊推出了輕量級(jí)圖形庫(kù) TinyGUI (此外,我也推出了一個(gè) WinForm 的框架,和 .Net Framework 保持兼容,適合喜歡 WinForm 開(kāi)發(fā)的用戶,不過(guò)這個(gè)不是輕量級(jí)的,參見(jiàn)《 開(kāi)源 System.Windows.Forms 庫(kù),讓 .Net Micro Framework 界面開(kāi)發(fā)和上位機(jī)一樣簡(jiǎn)單 》)。

TinyGUI 的相關(guān)介紹,在我早期的一篇 Blog 中已經(jīng)有介紹了,所以不知道 TinyGUI 為何物的讀者,可以先看看這篇文章《 【玩轉(zhuǎn) .Net MF 06 】為 Cortex-M3 打造輕量級(jí) TinyGUI (上) 》。

TinyGUI 接口非常簡(jiǎn)單,相關(guān)聲明如下:

public sealed class Graphics

{

public Graphics();

public static void Clear( uint color);

public static void DrawEllipse( int x, int y, int width, int height, uint color);

public static void DrawImage( int x, int y, byte [] bytData);

public static void DrawImageEx( int x, int y, byte [] bytData, uint MaskColor);

public static void DrawLine( int x1, int y1, int x2, int y2, uint color);

public static void DrawRectangle( int x, int y, int width, int height, uint color);

public static void DrawString( int x, int y, string s, uint color);

public static void FillEllipse( int x, int y, int width, int height, uint color);

public static void FillRectangle( int x, int y, int width, int height, uint color);

public static uint GetPixel( int x, int y);

public static void Print( string str);

public static void SetPixel( int x, int y, uint color);

}

相關(guān)繪圖示例如下(這就是我以前提供圖形示例 pe 文件的源碼)

public static void Main()

{

uint [] colors = new uint []{ Color .Black, Color .Red, Color .Green, Color .Orange, Color .Yellow, Color .Brown, Color .Purple, Color .Gray,

Color .DarkGray, Color .LightGray, Color .Blue, Color .Magenta, Color .Cyan, Color .White, Color .LightGreen};

Graphics .Clear( Color .Blue);

int x, y, width, height,c;

long index = 0;

Random rnd = new Random ();

while ( true )

{

x = rnd.Next(239);

width = rnd.Next(239 - x);

y = rnd.Next(319);

height = rnd.Next(319 - y);

c = rnd.Next(colors.Length-1);

switch (index % 3)

{

case 0:

if (rnd.Next(10) > 5)

Graphics .DrawRectangle(x, y, width, height, colors[c]);

else

Graphics .FillRectangle(x, y, width, height, colors[c]);

break ;

case 1:

if (rnd.Next(10) > 5)

Graphics .DrawEllipse(x, y, width, height, colors[c]);

else

Graphics .FillEllipse(x, y, width, height, colors[c]);

break ;

case 2:

Graphics .DrawLine(x, y, rnd.Next(239), rnd.Next(319), colors[c]);

break ;

}

Graphics .FillRectangle(0, 300, 239, 19, Color .White);

Graphics .DrawString(2, 303, (index++).ToString(), Color .Blue);

Thread .Sleep(50);

}

}

代碼比較簡(jiǎn)單,這里我就不過(guò)多解釋了。需要說(shuō)明的是,該程序不能直接在模擬器中運(yùn)行,并且需要引用 System.TinyGUI.dll 庫(kù)。

運(yùn)行后的結(jié)果如下:

【STM32 .Net MF開(kāi)發(fā)板學(xué)習(xí)-03】TinyGUI繪圖示例

至于如何制作和顯示 TinyBMP 格式的位圖我們下篇文章再進(jìn)行介紹。

-----------------------------------------------------------------------------------------

源碼下載: http://www.sky-walker.com.cn/yefan/MFV40/SourceCode/TinyGUI_Sample.rar

相關(guān)鏈接:《 免費(fèi)發(fā)放 firmwave ,打造史上最低價(jià) .Net MF 開(kāi)發(fā)板

.Net Micro Framework 快速入門

中文討論組: http://space.cnblogs.com/group/MFSoft/

【STM32 .Net MF開(kāi)發(fā)板學(xué)習(xí)-03】TinyGUI繪圖示例


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 庄河市| 九龙城区| 汝阳县| 安丘市| 襄垣县| 柳河县| 定陶县| 扶沟县| 内乡县| 来安县| 陕西省| 来宾市| 新源县| 资阳市| 双城市| 江津市| 四平市| 彰化县| 中牟县| 师宗县| 高尔夫| 鲁山县| 清远市| 大理市| 高平市| 任丘市| 福建省| 涡阳县| 祁阳县| 信丰县| 枝江市| 平阴县| 凤阳县| 涞源县| 扶风县| 江门市| 车险| 福鼎市| 昌宁县| 海宁市| 襄垣县|