GDI 吗?有标准图像编码器 CLSID 吗?
GDI+ Image::Save
方法需要一个 CLSID 参数来指定要使用的编码器。该文档指向一些示例代码获取与特定 MIME 类型(例如 image/jpeg 或 image/png)关联的编码器。然而,我对复制半页函数只是为了支持 1 行调试辅助(将中间结果保存到磁盘)的想法犹豫不决。
难道不应该有一个标准编码器的标准 CLSID 列表吗?我在哪里可以找到这样的列表?我通过搜索 Microsoft 的包含文件没有找到一个。
The GDI+ Image::Save
method requires a CLSID parameter to specify the encoder to use. The documentation points to some sample code for getting the encoder associated with a particular MIME type, such as image/jpeg or image/png. However I'm balking at the thought of copying a half-page function just to support a 1-line debugging aid where I save an intermediate result out to disk.
Shouldn't there be a list of standard CLSIDs for the standard encoders? Where would I find such a list? I haven't been able to find one by searching Microsoft's include files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有一个。我认为他们希望编解码器列表可扩展并支持插件,但从未抽出时间来实现。鉴于他们已经相当长一段时间没有对 GDI+ 进行任何更改,他们很可能不会很快这样做。您可能可以根据 Gdiplus::GetImageEncoders 的枚举生成自己的硬编码列表。
也就是说:
这是我经常在项目之间剪切和粘贴的函数,用于获取编码器的 CLSID。您可以将其修改为表查找。
There isn't one. I think they intended the codec list to be extensible and support plugins, but never got around to it. Given that they haven't made any changes to GDI+ in quite some time, they likely won't anytime soon. You could probably get away with generating your own hard coded list based on an enumeration of Gdiplus::GetImageEncoders.
That is:
Here's the function I routinely cut&paste between projects for getting at the CLSID of the encoder. You could modify it to be a table lookup.
如果您只想编写 PNG,这似乎可行:
注意十六进制值的重新格式化。
从:
如何初始化常量 CLSID
If you just want to write a PNG, this appears to work:
Note the reformatting of the hex values.
From:
How to initialize a constant CLSID
您可能希望将
ImageCodecInfo
与GetImageEncodersSize()
和GetImageEncoders()
一起使用,我不知道有任何更简单的方法。编辑:如果你明确知道自己想要什么,而其余的都该死,那么你可以做这样的事情......
You will probably want to use
ImageCodecInfo
withGetImageEncodersSize()
andGetImageEncoders()
I'm not aware of any easier way.EDIT: If you know specifically what you want and damn all the rest you can get away with doing something like this ...