简体   繁体   English

绘制矩形(边界或整个区域)(C#)时透明度如何工作?

[英]How transparency works in drawing rectangle(border or whole area)(C#)?

I have a colormap plot and want to apply mesh dimensions on the picture plot. 我有一个色图,想在图片上应用网格尺寸。 This request was successfully done by using the following code: 使用以下代码已成功完成此请求:

// draw mesh pattern
                        Pen transPen = new Pen(Color.FromArgb(128, 150, 150, 150),2);
                        g.DrawRectangle(transPen, (float)X,
                            (float)Y,
                            (float)dx,
                            (float)dy);

// draw contour square (brush , x , y , dx , dy)
                        g.FillRectangle(myContourBrush,
                            (float)X,
                            (float)Y,
                            (float)dx,
                            (float)dy);

Now my question is : the first transparent rectangle are transparent just in border area or all rectangle area? 现在我的问题是:第一个透明矩形在边框区域还是所有矩形区域中都是透明的? I don't want to affect colormap color, I just want to have mesh pattern. 我不想影响颜色图的颜色,我只想拥有网格图案。

The DrawRectangle method only draws the edge. DrawRectangle方法仅绘制边缘。 If you want to fill it, you must use FillRectangle . 如果要填充它,则必须使用FillRectangle Take a look for yourself. 看看自己。 You might have to zoom in quite a bit to notice the color change. 您可能需要放大很多才能注意到颜色的变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM