问题描述
这就是我使用 GDI+ 的方式;
Graphics g(hdc);
int width = 100; // set width
int height = 50; // set height
int shadowSize = 5; // set the size of the Shadow
SolidBrush solid((Color(255,74,134,232))); // Set the solid fill color.
SolidBrush shadow((Color(40,0))); // Set transparent fill color.
g.FillRectangle(&shadow,x,y,width,height); //(1) // Draw the transparent rectangle,this will be at the background.
x = shadowSize/2; // divide the shadowsize to 2 to make it center.
y = shadowSize/2; // divide the shadowsize to 2 to make it center.
width = width - shadowSize; // Deduct the size of the shadow to the width and height to get the same size we wanted.
height = height - shadowSize;
g.FillRectangle(&solid,height); //(2) // Draw the solid rectangle,this will be in the front of the transparent rectangle.
DeleteObject(&shadow); //always delete object
DeleteObject(&solid); //always delete object
好吧,它会起作用,但是,这实际上不是阴影效果,它只是一个矩形,后面有一个透明矩形。如果我希望阴影更大,效果将不会被欣赏。它应该像发光、模糊之类的东西。
那么如何绘制具有阴影效果的对象?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)