绘制一个低不透明度的填充矩形 [英] Draw a Fill Rectangle with low opacity

查看:22
本文介绍了绘制一个低不透明度的填充矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 语言的 Windows 窗体应用程序中有一个带有图片的图片框.我想在图片框的某个位置绘制一个 FillRectangle.但我还需要查看图片框的图片.我该如何绘制这个矩形 低不透明度可以看到图片框的图像?

I a have a PictureBox with a picture in a Windows Form application in C# language.I want draw a FillRectangle in some location of picturebox.but i also need to see picture of picture box.how can i draw this rectangle with low opacity to see image of picturebox?

推荐答案

你的意思是:

using (Graphics g = Graphics.FromImage(pb.Image))
{
    using(Brush brush = new SolidBrush(your_color))
    {
        g.FillRectangle(brush , x, y, width, height);
    }
}

或者你可以使用

Brush brush = new SolidBrush(Color.FromArgb(alpha, red, green, blue))

其中 alpha 从 0 到 255,因此 alpha 值为 128 将为您提供 50%不透明度.

where alpha goes from 0 to 255, so a value of 128 for your alpha will give you 50% opactity.

这篇关于绘制一个低不透明度的填充矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆