|
4 | 4 | #include <LCUI/image.h>
|
5 | 5 | #include <LCUI/font.h>
|
6 | 6 |
|
7 |
| -int main( void ) |
| 7 | +int main(void) |
8 | 8 | {
|
9 | 9 | int ret;
|
10 | 10 | LCUI_Graph img;
|
11 |
| - LCUI_Pos pos = {0, 80}; |
12 |
| - LCUI_Rect area = {0, 0, 320, 240}; |
| 11 | + LCUI_Pos pos = { 0, 80 }; |
| 12 | + LCUI_Rect area = { 0, 0, 320, 240 }; |
13 | 13 | LCUI_TextLayer txt = TextLayer_New();
|
14 | 14 | LCUI_TextStyleRec txtstyle;
|
15 | 15 |
|
16 | 16 | /* 初始化字体处理功能 */
|
17 | 17 | LCUI_InitFontLibrary();
|
18 | 18 |
|
19 | 19 | /* 创建一个图像,并使用灰色填充 */
|
20 |
| - Graph_Init( &img ); |
21 |
| - Graph_Create( &img, 320, 240 ); |
22 |
| - Graph_FillRect( &img, RGB( 240, 240, 240 ), NULL, FALSE ); |
| 20 | + Graph_Init(&img); |
| 21 | + Graph_Create(&img, 320, 240); |
| 22 | + Graph_FillRect(&img, RGB(240, 240, 240), NULL, FALSE); |
23 | 23 |
|
24 | 24 | /* 设置文本的字体大小 */
|
25 |
| - TextStyle_Init( &txtstyle ); |
| 25 | + TextStyle_Init(&txtstyle); |
26 | 26 | txtstyle.pixel_size = 24;
|
27 | 27 | txtstyle.has_pixel_size = TRUE;
|
28 | 28 |
|
29 | 29 | /* 设置文本图层的固定尺寸、文本样式、文本内容、对齐方式 */
|
30 |
| - TextLayer_SetFixedSize( txt, 320, 240 ); |
31 |
| - TextLayer_SetTextStyle( txt, &txtstyle ); |
32 |
| - TextLayer_SetTextAlign( txt, SV_CENTER ); |
33 |
| - TextLayer_SetTextW( txt, L"这是一段测试文本\nHello, World!", NULL ); |
34 |
| - TextLayer_Update( txt, NULL ); |
| 30 | + TextLayer_SetFixedSize(txt, 320, 240); |
| 31 | + TextLayer_SetTextStyle(txt, &txtstyle); |
| 32 | + TextLayer_SetTextAlign(txt, SV_CENTER); |
| 33 | + TextLayer_SetTextW(txt, L"这是一段测试文本\nHello, World!", NULL); |
| 34 | + TextLayer_Update(txt, NULL); |
35 | 35 |
|
36 | 36 | /* 将文本图层绘制到图像中,然后将图像写入至 png 文件中 */
|
37 |
| - TextLayer_RenderTo( txt, area, pos, &img ); |
38 |
| - ret = LCUI_WritePNGFile( "test_string_render.png", &img ); |
39 |
| - Graph_Free( &img ); |
| 37 | + TextLayer_RenderTo(txt, area, pos, &img); |
| 38 | + ret = LCUI_WritePNGFile("test_string_render.png", &img); |
| 39 | + Graph_Free(&img); |
40 | 40 |
|
41 | 41 | /* 释放字体处理功能相关资源 */
|
42 | 42 | LCUI_FreeFontLibrary();
|
|
0 commit comments