mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-12-01 16:56:34 +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>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
#include <LCUI.h>
|
|
#include <LCUI/image.h>
|
|
#include <LCUI/font.h>
|
|
#include <LCUI/graph.h>
|
|
|
|
int main(void)
|
|
{
|
|
int ret, fid;
|
|
LCUI_Graph img;
|
|
LCUI_FontBitmap bmp;
|
|
LCUI_Pos pos = { 25, 25 };
|
|
LCUI_Color bg = RGB(240, 240, 240);
|
|
LCUI_Color color = RGB(255, 0, 0);
|
|
|
|
/* 初始化字体处理功能 */
|
|
LCUI_InitFontLibrary();
|
|
|
|
/* 创建一个画布,并填充背景为灰色 */
|
|
Graph_Init(&img);
|
|
Graph_Create(&img, 100, 100);
|
|
Graph_FillRect(&img, bg, NULL, FALSE);
|
|
|
|
/* 载入字体文件 */
|
|
ret = LCUIFont_LoadFile("C:/Windows/fonts/simsun.ttc");
|
|
while (ret == 0) {
|
|
/* 获取字体ID */
|
|
fid = LCUIFont_GetId("SimSun", 0, 0);
|
|
if (fid < 0) {
|
|
break;
|
|
}
|
|
/* 渲染对应的文字位图,大小为 48 像素 */
|
|
ret = LCUIFont_RenderBitmap(&bmp, L'字', fid, 48);
|
|
if (ret != 0) {
|
|
break;
|
|
}
|
|
/* 绘制红色文字到图像上 */
|
|
FontBitmap_Mix(&img, pos, &bmp, color);
|
|
LCUI_WritePNGFile("test_char_render.png", &img);
|
|
/* 释放内存资源 */
|
|
FontBitmap_Free(&bmp);
|
|
Graph_Free(&img);
|
|
break;
|
|
}
|
|
|
|
/* 释放字体处理功能相关资源 */
|
|
LCUI_FreeFontLibrary();
|
|
return ret;
|
|
}
|