如何创建简单的玻璃效果
我目前正在自己绘制的对象上绘制浅蓝色、部分透明的覆盖层以指示某种状态。没关系,但我认为如果我能以某种玻璃效果来进一步确立特定物体上面覆盖有“东西”的想法,那就更好了。
例如,我认为除了蓝色透明度之外,一些玻璃条纹也会产生很好的效果。
我在 Google 上搜索过 GDI+(和其他)算法来完成像这样的简单绘画,但一无所获。任何语言的任何(相当简单)算法的链接将不胜感激。我更喜欢 .NET,但可以从伪代码中找出绘画。
抱歉,还应该指定我需要以 WinXP 为目标并使用 .NET 版本 2.0 - 因此无法使用 WPF 或 Vista/Win7 功能。
I am currently painting a light blue, partly transparent overlay over owner-drawn objects to indicate certain state. It's OK but I thought that it would be even nicer if I could at some sort of glass effect to further establish the idea that the particular object has "something" overlaid over the top of it.
I thought that some glass streaks, for example, in addition to the blue transparency would lend a nice effect.
I've Googled around for GDI+ (and others) algorithms to do simple things painting like this but have come up empty. Links to any (fairly simple) algorithms in any language would be appreciated. I prefer .NET but can figure out the painting from pseudo-code on up.
Sorry, shoul've also specified that I need to target WinXP and using .NET version 2.0 - So unable to use WPF or Vista/Win7 goodies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我自己没有这样做,但是使用了 codeproject 源来渲染示例...尝试一下:
http://www.codeproject.com/KB/GDI-plus/Image-Glass-Reflection.aspx
I've not done this myself but, have used codeproject source to render a sample...Try this:
http://www.codeproject.com/KB/GDI-plus/Image-Glass-Reflection.aspx
实际上,我通过在图像上覆盖一个大小约为下图三分之一的矩形来实现基本的玻璃效果,该矩形包含白色渐变填充,从 25% 不透明度开始一直到 75% 不透明度。这一点绘画产生了我很满意的玻璃状“条纹”。可以使用不同的矩形宽度重复相同的想法多次,以产生多个“条纹”,从而产生玻璃覆盖层的错觉。
I was actually able to achieve a basic glass effect by overlaying my image with a rectangle about one third the size of the image below that contains a gradient fill of white that starts at 25% opacity and goes to 75% opacity. This is single bit of painting produces a glassy "streak" that I was happy with. The same idea could be repeated a number of times with a variety of rect widths to produce several "streaks" that will give the illusion of a glass overlay.
如果您使用的是 Vista 或 Windows 7,您可以尝试 Aero Glass 功能。
这些可能会有所帮助:
http://msdn.microsoft.com/en-us/library/aa969537%28VS.85%29.aspx#blurbehind
http://msdn.microsoft.com/en-us/library/ms748975。 ASPX
You could try the Aero Glass function, if you are using Vista or Windows 7.
These might be helpful:
http://msdn.microsoft.com/en-us/library/aa969537%28VS.85%29.aspx#blurbehind
http://msdn.microsoft.com/en-us/library/ms748975.aspx