Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[建议]关于获取动态头像与动图透明背景的建议 #92

Open
Huaxidesu opened this issue May 28, 2023 · 3 comments
Open

[建议]关于获取动态头像与动图透明背景的建议 #92

Huaxidesu opened this issue May 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Huaxidesu
Copy link

希望可以支持获取动态头像,动态图生成可以兼容透明背景

@Dituon
Copy link
Owner

Dituon commented May 28, 2023

Plugin

获取动态头像: Mirai未提供正确的头像URL

mamoe/mirai#1557

Core

GIF支持透明色: 暂未找到合适的实现方式

  1. GIF使用 索引颜色 不支持 alpha颜色通道, 通过索引表示完全透明的颜色, 调色板最大为256色
  2. 将合成后的位图转换为 索引颜色 BufferedImage.TYPE_3BYTE_BGR 后会丢失原有的alpha通道
  3. 为保证转换后带有alpha通道的颜色准确显示, 在转换前的图片底部绘制白色背景 #fff

举例说明:

  • 带有alpha颜色通道的像素显示的实际颜色与图像查看程序的背景颜色有关
  • 丢弃alpha通道会导致「原本半透明的像素变得不透明」
  • 如果仅将 alpha > 0 的像素底部绘制 #fff 背景色, 会导致「在背景色为 #000 的图像查看程序下, 低不透明度与0不透明度像素颜色相差过大」

详见 BaseGifMaker.javaFastAnimatedGifEncoder.java

@Dituon Dituon closed this as completed May 31, 2023
@Dituon
Copy link
Owner

Dituon commented Oct 26, 2023

Try v6.0

新增 自动获取正确分辨率的头像

https://github.com/Dituon/petpet/releases/tag/6.0

@Dituon Dituon added the enhancement New feature or request label Nov 23, 2023
@Dituon
Copy link
Owner

Dituon commented Nov 23, 2023

下个版本会引入Rust构建的渲染核心,支持处理带有alpha通道的调色板,可以构建透明背景的GIF。

https://github.com/Dituon/petpet-rs

@Dituon Dituon reopened this Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants