Baji_Rtc_Toy/main/dzbj/dual_gif_demo.h
Rdzleo eb96130fc9 feat(Rtc_AIavatar): 数字人透明 GIF 显示方案 PoC 完成(背景图+透明GIF叠加)
源代码变更:
- main/dzbj/bg_gif_demo.c/h: 方案 C 最终实现 - JPG 背景图(lv_img) + 透明 GIF(lv_gif) 叠加
- main/dzbj/dual_gif_demo.c/h: 方案 B 中间产物 - 双 GIF 循环切换
- main/dzbj/sprite_demo.c/h: 方案 A 已弃用 - DMA 直写 GRAM 与 LVGL 争抢 LCD IO 失败
- main/dzbj/ai_chat_ui.c: 集成 USE_BG_GIF_POC 开关,加载背景图+透明 GIF
- main/dzbj/lcd.c: panel_handle 移除 static,便于其他模块访问
- main/CMakeLists.txt: 新增 3 个 dzbj 模块编译

资源新增:
- spiffs_image/Background_360x360.jpg: 设备背景图(20KB)
- spiffs_image/hiyori_m05.gif: Cubism Editor 直接导出的透明 GIF(2.3MB)
- docs/Rtc_AIavatar/: Live2D 模型(Hiyori/Haru) + 32 段 Haru GIF + 方案文档第18章 PoC 实战记录
- tools/sprite_poc/: Python GIF→RGB565 转换脚本

踩坑要点(详见 docs/Rtc_AIavatar 第18章):
- PIL Image.quantize() 会破坏 RGBA 透明度,必须改用 gifsicle
- PIL 保存动画 GIF 仅第1帧有透明,后续帧不透明 - LVGL gifdec 按帧读取
- Cubism Editor 直接导出 GIF 才能逐帧保留透明信息(FREE 版限制部分模型)
- gifsicle --lossy 会严重锯齿化,去掉只保留 --colors 256 + -O3 即可
- 裁剪居中需用全帧 bbox 不能只看第1帧(Live2D 角色每帧位置有偏移)
- LVGL 默认不支持 PNG,背景图用 JPG + esp_jpeg 解码到 RGB565 buffer
- 透明 GIF 显示黑色背景: gifdec.c canvas 初始化 alpha 须改为 0x00
2026-05-12 17:14:49 +08:00

40 lines
1.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* dual_gif_demo.h — 两个 GIF 循环交替播放
*
* 用 LVGL lv_gif 控件 + 单一控件切换 src 实现循环播放:
* GIF1播完 → GIF2播完 → GIF1 → ...
*
* 优化点:
* - 共用一个 lv_gif 控件,不重建(背景区域不刷新)
* - GIF 数据直接从 SPIFFS 加载到 PSRAM
* - 用 lv_timer 按 GIF 实际时长周期切换
*/
#pragma once
#include "esp_err.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* 启动双 GIF 循环播放
*
* @param path1 第一个 GIF 文件路径,例如 "/spiflash/dance_0_gesture.gif"
* @param dur1_ms 第一个 GIF 完整播放一遍的时长(毫秒)
* @param path2 第二个 GIF 文件路径
* @param dur2_ms 第二个 GIF 完整播放一遍的时长(毫秒)
* @return ESP_OK 成功
*/
esp_err_t dual_gif_demo_start(const char *path1, uint32_t dur1_ms,
const char *path2, uint32_t dur2_ms);
void dual_gif_demo_stop(void);
bool dual_gif_demo_is_playing(void);
#ifdef __cplusplus
}
#endif