如何以编程方式创建“明亮”的效果和一个“灰色”;图标的版本?
在 win32 应用程序中,我想要一个带有图标的按钮,当按钮被禁用时,该图标看起来呈灰色,而当鼠标悬停时,该图标看起来“更亮”。
我知道我可以使用图标编辑器创建三个位图,但由于用户可以选择图标并从磁盘加载图标,所以我想以编程方式创建其他两个版本。
因此,从图像的句柄开始,我想:
- 创建一个新图像,将所有颜色转换为灰色。
- 创建一个新图像,所有颜色都变为白色或黄色。
可以使用 win32 api 调用来完成此操作吗?
任何语言的示例将不胜感激。
In a win32 application, I want to have a button with an icon which looks gray when the button is disabled and 'brighter' when the mouse hovers.
I know I can create three bitmaps with an icon editor, but since the icon can be user selected and loaded from the disk, I would like to create the other two versions programmatically.
So, starting with a handle to an image, I would like to:
- Create a new image with all colors converted to grey.
- Create a new image with all colors shifted to white or yellow.
Can this be done using win32 api calls?
Examples in any language will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许旧的 DrawState 函数就足够了。 (出于某种原因,它现在被列为仅在 Win2000 中可用,但事实并非如此。)
也许不是,在这种情况下您可能需要使用 SetColorAdjustment 函数。
Maybe the good old DrawState function will suffice. (For some reason it is now listed as only available from Win2000 which is not true.)
And maybe not, in which case you might want to use SetColorAdjustment function.
如果图标是用户选择的,您可以控制格式吗?如果没有,您可能会想要合并一个图像库或外部进程,如 DevIL 或 Imagemagick,它们处理的格式比 Microsoft API 可能处理的格式更多。
If the icon is user-selected do you control the format? If not you'll probably want to incorporate an image library or external process like DevIL or Imagemagick which handle more formats than Microsofts API's are likely to..