Skip to content

Add wmf support #54

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

Open
wants to merge 150 commits into
base: master
Choose a base branch
from
Open

Add wmf support #54

wants to merge 150 commits into from

Conversation

lindexi
Copy link
Member

@lindexi lindexi commented Jul 29, 2025

  • 支持多发布一个包: DotNetCampus.MediaConverter.SkiaWmfRenderer
    • 完全 C# 托管代码实现的 WMF 库,使用 Skia 渲染
    • 没有受到 ImageSharp 影响,可以 MIT 协议开源,可 DLL 引用
  • 各个平台添加 libWmf 的引用,让其转换为 svg 图片格式,再使用 SVG.Skia 转换为 png 格式图片
    • 因为直接使用 wmf2gd 直接转换为 png 图片时,没有处理好文本渲染以及抗锯齿等逻辑,渲染比较糟糕。看文件大小也能知道,没有带全渲染。于是就使用 wmf2svg 先转换为 svg 再利用 skia 的渲染,将其渲染为 png 格式图片
    • 由于整个 libwmf 对于 symbol 等的支持是缺失的,导致遇到 symbol 字符就会转换为 0xFFFD 字符。这个 0xFFFD 就是 UTF8 的未知字符,渲染出来就是一个棱形方框。因此我就尝试自己实现渲染,具体做法如下
    • 由于 wmf2svg 需要字体的支持,于是就带了一些字体,带的字体本身都是免费的
    • 自己绘制渲染也需要 Symbol 字体,同样也带了免费的字体

原图:

image

wmf2svg + SVG.Skia 效果 Windows:

image

wmf2svg + SVG.Skia 效果 Linux 不带字体:

image

image

自己写的 SkiaWmfRenderer 渲染效果 Windows:

WMF_image17

自己写的 SkiaWmfRenderer 渲染效果 Linux:

Test_tto0mlr4

@lindexi
Copy link
Member Author

lindexi commented Aug 14, 2025

关联 SixLabors/ImageSharp#2837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants