什么是 BitmapData.reserved?

发布于 2024-11-16 11:36:42 字数 153 浏览 6 评论 0原文

BitmapData 有一个名为 Reserved 的属性,它返回一个 32 位有符号 整数。微软的文档说不要使用这个属性。如果我们不应该使用它;那为什么它会在那里呢?它究竟是做什么用的?

BitmapData has a property called Reserved, which returns a 32-bit signed integer. Microsoft's documentation says not to use this property. If we shouldn't use it; then why is it there? What exactly is it for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岛徒 2024-11-23 11:36:42

保留字段和属性可以有多种用途。一种相当常见的用法是允许更复杂类型的 BitmapData 将来可能需要存储当前结构未提供的某种类型的信息。如果没有人使用保留字段做任何事情,则未来的实现可以使用该字段来保存指向包含附加信息的另一个结构的指针或句柄。

Reserved fields and properties can have a variety of uses. One fairly common usage is to allow for the possibility that more sophisticated types of BitmapData may in future need to store some type of information for which the present structure makes no provision. If nobody has used the Reserved field for anything, future implementations could use that field to hold a pointer or handle to another structure containing additional information.

瞄了个咪的 2024-11-23 11:36:42

有趣的是,这是一个错误。它实际上是一个 IntPtr,你可以从 SDK 中的原生声明 GdiPlusImaging.h 头文件(VS2008 的 c:\program files\microsoft sdks\windows\v6.0a\include 目录)中看出。该错误不会字节化,因为 GDI+ 创建了它的实例。

这使得该字段可能存储指针或句柄。我会猜测内存映射文件对象句柄。将其存储在客户端状态对象中比必须维护字典以在 UnlockBits() 函数中找到它要便宜。别乱搞它。

Interesting, that's a bug. It is actually an IntPtr, you can tell from the native declaration, GdiPlusImaging.h header file in the SDK (c:\program files\microsoft sdks\windows\v6.0a\include directory for VS2008). The bug doesn't byte because GDI+ creates the instance of it.

Which makes it likely that the field stores a pointer or a handle. I would guess at the memory mapped file object handle. Cheaper to store it in the client state object over having to maintain a dictionary to find it back in the UnlockBits() function. Don't mess with it.

め可乐爱微笑 2024-11-23 11:36:42

Microsoft 较旧的 API 中有很多这样的内容,它们源于在属性集中为未来的开发工作留出空间的普遍做法。它们的作用与没人应该按下的红色大按钮相同。也许将来有人会想要一个按钮,然后,好吧,我们已经在这里拥有了这个按钮!

There are a lot of these in Microsoft's older APIs, and they stem from a time when it was common to put space in property sets for future development efforts. They serve the same purpose as a big red button that nobody is supposed to push. Maybe someone will want a button in the future, and then, well, we've already got this one right here!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文