7

dotnet 读 WPF 源代码笔记 WIC 多媒体图片处理通过 WindowsCodecs.dll 实现功能

 3 years ago
source link: https://lindexi.gitee.io/post/dotnet-%E8%AF%BB-WPF-%E6%BA%90%E4%BB%A3%E7%A0%81%E7%AC%94%E8%AE%B0-WIC-%E5%A4%9A%E5%AA%92%E4%BD%93%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86%E9%80%9A%E8%BF%87-WindowsCodecs.dll-%E5%AE%9E%E7%8E%B0%E5%8A%9F%E8%83%BD.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
dotnet 读 WPF 源代码笔记 WIC 多媒体图片处理通过 WindowsCodecs.dll 实现功能

本文是我在读 WPF 源代码做的笔记

在 WPF 中,作为一个现代化的 UI 框架,自然有很多多媒体相关的事情需要处理,在 WPF 中有特别的一层是 WIC 层,这一层将包揽了大部分的多媒体图片的处理。如咱熟悉的 BitmapEncoder 类,里面就有大量调用到 WIC 的逻辑

那么在 WPF 中说的 WIC 层是什么?通过 官方文档 可以了解到 WIC 就是 Windows Imaging Component 的缩写,专门用来处理图片相关的逻辑

在用户端的代码逻辑放在 WindowsCodecs.dll 文件里面,这个文件是跟随系统的,由系统带出去的。听到这句话,是不是有很多小伙计觉得这又是坑呢?被系统带出去的,意味着依然还会有一些有趣的系统瞎改这个文件。这也就是在即使使用 dotnet core 版本的 WPF 也许会遇到有多媒体图片渲染失败的一个原因了,当然了我这么久也没有听到有小伙伴和我反馈遇到此问题

在 WPF 里面使用到 WIC 的底层调用的逻辑,可以通过在 src\Microsoft.DotNet.Wpf\src\Shared\RefAssemblyAttrs.cs 的 DllImport 代码里面,使用 Resharper 找到 WindowsCodecs 的所有引用,来了解这部分的调用

    internal static class DllImport
    {
        internal const string PresentationNative = "PresentationNative" + BuildInfo.WCP_VERSION_SUFFIX + ".dll";
        internal const string PresentationCFFRasterizerNative = "PresentationCFFRasterizerNative" + BuildInfo.WCP_VERSION_SUFFIX + ".dll";
        internal const string MilCore = "wpfgfx" + BuildInfo.WCP_VERSION_SUFFIX + ".dll";

        // DLL's w/o version suffix
        internal const string UIAutomationCore = "UIAutomationCore.dll";
        internal const string Wininet = "Wininet.dll";
        internal const string WindowsCodecs = "WindowsCodecs.dll";
        internal const string WindowsCodecsExt = "WindowsCodecsExt.dll";
        internal const string Mscms = "mscms.dll";
        internal const string PrntvPt = "prntvpt.dll";
        internal const string Ole32 = "ole32.dll";
        internal const string User32 = "user32.dll";
        internal const string NInput = "ninput.dll";
        internal const string ApiSetWinRT = "api-ms-win-core-winrt-l1-1-0.dll";
        internal const string ApiSetWinRTString = "api-ms-win-core-winrt-string-l1-1-0.dll";
    }

按照这个逻辑来说,即使 WPF 层啥都不做,随着系统版本的更新,在 WIC 层的性能提升也会让整个 WPF 的多媒体图片渲染和解码的性能有所提升,但是我考古了一会没有发现权威的文档,还请大法们帮忙找找

当前的 WPF 在 https://github.com/dotnet/wpf 完全开源,使用友好的 MIT 协议,意味着允许任何人任何组织和企业任意处置,包括使用,复制,修改,合并,发表,分发,再授权,或者销售。在仓库里面包含了完全的构建逻辑,只需要本地的网络足够好(因为需要下载一堆构建工具),即可进行本地构建


本文会经常更新,请阅读原文: https://blog.lindexi.com/post/dotnet-%E8%AF%BB-WPF-%E6%BA%90%E4%BB%A3%E7%A0%81%E7%AC%94%E8%AE%B0-WIC-%E5%A4%9A%E5%AA%92%E4%BD%93%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86%E9%80%9A%E8%BF%87-WindowsCodecs.dll-%E5%AE%9E%E7%8E%B0%E5%8A%9F%E8%83%BD.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。

如果你想持续阅读我的最新博客,请点击 RSS 订阅,推荐使用RSS Stalker订阅博客,或者前往 CSDN 关注我的主页

本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接: https://blog.lindexi.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系

无盈利,不卖课,做纯粹的技术博客

以下是广告时间

推荐关注 Edi.Wang 的公众号
lindexi%2F201985113622445

欢迎进入 Eleven 老师组建的 .NET 社区
lindexi%2F20209121930471745.jpg

以上广告全是友情推广,无盈利


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK