3295
- 收藏
- 点赞
- 分享
- 举报
SDL库无法生成ARGB1555的图片是怎么回事?
参考了本论坛关于海思OSD的方法 http://bbs.ebaina.com/forum.php?mod=viewthread&tid=10879&extra=&page=2
http://bbs.ebaina.com/forum.php?mod=viewthread&tid=11772&highlight=SDL
写了代码测试将时间字符串转为ARGB1555;
[code]#include
include "SDL.h"
include "SDL_ttf.h"
include
int main(int argc, const char argv[]) { char pstr[18]; SDL_PixelFormat fmt; TTF_Font font; SDL_Surface text, *temp; time_t time_seconds = time(NULL); struct tm now_time; localtime_r(&time_seconds, &now_time); sprintf(pstr,"%04d-%02d-%02d %02d:%02d:%02d", now_time.tm_year + 1900, now_time.tm_mon + 1, now_time.tm_mday, now_time.tm_hour, now_time.tm_min, now_time.tm_sec); if (TTF_Init() < 0 ) { fprintf(stderr, "Couldn't initialize TTF: %s\n", SDL_GetError()); SDL_Quit(); }
font = TTF_OpenFont("./simhei.ttf", 48);
if ( font == NULL )
{
fprintf(stderr, "Couldn't load %d pt font from %s: %s\n", 18, "ptsize", SDL_GetError());
}
SDL_Color forecol= { 0xff, 0xff, 0xff, 0 };
text = TTF_RenderUTF8_Solid(font, pstr, forecol);
temp = SDL_CreateRGBSurface(SDL_SWSURFACE,text->w, text->h, 16 ,0x00000000, 0x00000000, 0x00000000,0x00000000);
SDL_Rect bounds;
if (temp != NULL)
{
bounds.x = 0;
bounds.y = 0;
bounds.w = text->w;
bounds.h = text->h;
if (SDL_LowerBlit(text, &bounds, temp, &bounds) < 0)
{
SDL_FreeSurface(text);
SDL_SetError("Couldn't convert image to 16 bpp");
text = NULL;
return -1;
}
}
else
{
printf("sdl failed\n");
return -1;
}
SDL_SaveBMP(temp, "save.bmp");
SDL_FreeSurface(text);
SDL_FreeSurface(temp);
TTF_CloseFont(font);
TTF_Quit();
return 0;
} [/code]
以上代码依然只能生成24位的图像,不知道是否参数设置有问题?
我来回答
回答8个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片
相关问答
-
2018-07-07 09:07:38
-
2018-03-29 19:50:50
-
2020-03-18 09:33:17
-
2016-06-28 20:12:08
-
2025-08-11 18:13:37
-
2019-01-04 15:53:19
-
2020-12-28 13:55:16
-
2019-01-27 12:02:54
-
2023-07-26 09:01:38
-
2016-08-11 20:01:35
-
2018-11-14 09:15:31
-
2019-04-23 11:47:53
-
2017-07-11 09:50:46
-
2019-01-29 16:35:46
-
2021-02-08 15:08:20
-
2021-01-13 13:48:51
-
2018-11-08 11:19:00
-
2021-02-24 15:29:13
-
2018-11-20 14:05:45
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5hisi3516cv610 + gc4336p 夜晚很模糊
-
5AIISP(功能演示,SC4336P为BGGR,强制转RGGB,会导致颜色异常)
-
5rv1106使用luckfox的SDK,设备树和驱动都写好了,结果设备文件没有生成
-
5海思3516cv610中如何进行SD卡升级,根据官方文档操作,烧录进板子时,走的默认uboot,没有执行uboot升级。
-
5G610Q-IPC-38E 夜晚很暗 有什么办法解决吗 已经补光了
-
10转换模型时,SoC版本里没显示hi3516cv610芯片
-
5hisi3516cv610 使用 yolov8n 模型训练 要如何提高 这里识别的是人
-
10有人在海思平台接过SC035HGS吗
-
5关于hi3519dv500,以SD卡虚拟 U 盘操作
-
5ss928 sample_venc代码移植到openEuler24.03上执行报错 [sample_comm_vi_start_dev]-1068: vi set dev attr failed wi
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认

微信扫码分享
QQ好友