我目前在所有者绘制的对象上绘制一个浅蓝色,部分透明的覆盖图,以指示某种状态。没关系,但我认为如果我可以通过某种玻璃效果来进一步确定特定物体的“东西”覆盖在它上面的想法会更好。
我认为,除了蓝色透明度之外,一些玻璃条纹会产生很好的效果。
我已经开始使用GDI +(以及其他)算法来做简单的事情,这样画画就像空洞一样。任何语言的任何(相当简单的)算法的链接将不胜感激。我更喜欢.NET,但可以从伪代码中找出这幅画。
对不起,还指出我需要针对WinXP并使用.NET 2.0版 - 所以无法使用WPF或Vista / Win7好东西。
答案 0 :(得分:1)
我自己没有这样做,但是,使用了codeproject源来渲染样本......试试这个:
http://www.codeproject.com/KB/GDI-plus/Image-Glass-Reflection.aspx
public static Image DrawReflection(Image _Image, Color _BackgroundColor, int _Reflectivity)
{
// Calculate the size of the new image
int height = (int)(_Image.Height + (_Image.Height * ((float)_Reflectivity / 255)));
Bitmap newImage = new Bitmap(_Image.Width, height, PixelFormat.Format24bppRgb);
newImage.SetResolution(_Image.HorizontalResolution, _Image.VerticalResolution);
using (Graphics graphics = Graphics.FromImage(newImage))
{
// Initialize main graphics buffer
graphics.Clear(_BackgroundColor);
graphics.DrawImage(_Image, new Point(0, 0));
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle destinationRectangle = new Rectangle(0, _Image.Size.Height,
_Image.Size.Width, _Image.Size.Height);
// Prepare the reflected image
int reflectionHeight = (_Image.Height * _Reflectivity) / 255;
Image reflectedImage = new Bitmap(_Image.Width, reflectionHeight);
// Draw just the reflection on a second graphics buffer
using (Graphics gReflection = Graphics.FromImage(reflectedImage))
{
gReflection.DrawImage(_Image,
new Rectangle(0, 0, reflectedImage.Width, reflectedImage.Height),
0, _Image.Height - reflectedImage.Height, reflectedImage.Width,
reflectedImage.Height, GraphicsUnit.Pixel);
}
reflectedImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
Rectangle imageRectangle =
new Rectangle(destinationRectangle.X, destinationRectangle.Y,
destinationRectangle.Width,
(destinationRectangle.Height * _Reflectivity) / 255);
// Draw the image on the original graphics
graphics.DrawImage(reflectedImage, imageRectangle);
// Finish the reflection using a gradiend brush
LinearGradientBrush brush = new LinearGradientBrush(imageRectangle,
Color.FromArgb(255 - _Reflectivity, _BackgroundColor),
_BackgroundColor, 90, false);
graphics.FillRectangle(brush, imageRectangle);
}
return newImage;
}
答案 1 :(得分:1)
我实际上能够通过将我的图像覆盖一个大约三分之一大小的矩形的矩形来实现基本的玻璃效果,该矩形包含从25%不透明度开始并且达到75%不透明度的白色渐变填充。这是一点点的绘画产生了一个玻璃状的“条纹”,我很高兴。同样的想法可以重复多次,具有各种矩形宽度,以产生几个“条纹”,这将产生玻璃覆盖层的错觉。
答案 2 :(得分:0)
如果您使用的是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