mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
* add yutil * add yutil to util.h * remove util file that same as yutil's * replace the old header file like '#include <LCUI/util/*>' with yutil's head file * Replace the old UTIL module associated data structures and function call code * change timer * Replace the old UTIL module associated data structures and function call code * fix * fix compilation problems(RGB to YUTIL_TEST_RGB) * turn some useless changes back to origin * change YUTIL_TEST_RGB back to RGB and add lcui-util/xmake.lua include * update github action * update github action * update github action * change new yutil func name * update xmake and change way to include yutil * update include to <yutil.h> * update list_for_each to for(list_each()) * fix * add graph.h to test_* * add #include <LCUI/graph.h> * update yutil * change timer func name and update submodule * update submodules * test strncpy * turn useless code back origin * fix lose RGB issue * fix yutil charset * update yutil * update yutil * add yutil_test instead of lcui-util test * change timer func name style Co-authored-by: 李梓豪 <yidianyiko@foxmail.com>
44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
#include <LCUI.h>
|
|
#include <LCUI/image.h>
|
|
#include <LCUI/font.h>
|
|
#include <LCUI/graph.h>
|
|
|
|
int main(void)
|
|
{
|
|
int ret;
|
|
LCUI_Graph img;
|
|
LCUI_Pos pos = { 0, 80 };
|
|
LCUI_Rect area = { 0, 0, 320, 240 };
|
|
LCUI_TextLayer txt = TextLayer_New();
|
|
LCUI_TextStyleRec txtstyle;
|
|
|
|
/* 初始化字体处理功能 */
|
|
LCUI_InitFontLibrary();
|
|
|
|
/* 创建一个图像,并使用灰色填充 */
|
|
Graph_Init(&img);
|
|
Graph_Create(&img, 320, 240);
|
|
Graph_FillRect(&img, RGB(240, 240, 240), NULL, FALSE);
|
|
|
|
/* 设置文本的字体大小 */
|
|
TextStyle_Init(&txtstyle);
|
|
txtstyle.pixel_size = 24;
|
|
txtstyle.has_pixel_size = TRUE;
|
|
|
|
/* 设置文本图层的固定尺寸、文本样式、文本内容、对齐方式 */
|
|
TextLayer_SetFixedSize(txt, 320, 240);
|
|
TextLayer_SetTextStyle(txt, &txtstyle);
|
|
TextLayer_SetTextAlign(txt, SV_CENTER);
|
|
TextLayer_SetTextW(txt, L"这是一段测试文本\nHello, World!", NULL);
|
|
TextLayer_Update(txt, NULL);
|
|
|
|
/* 将文本图层绘制到图像中,然后将图像写入至 png 文件中 */
|
|
TextLayer_RenderTo(txt, area, pos, &img);
|
|
ret = LCUI_WritePNGFile("test_string_render.png", &img);
|
|
Graph_Free(&img);
|
|
|
|
/* 释放字体处理功能相关资源 */
|
|
LCUI_FreeFontLibrary();
|
|
return ret;
|
|
}
|