我如何绘制一个矩形到图像具有透明度和文字 [英] How do I draw a rectangle onto an image with transparency and text
问题描述
这是我的第一个基于图形项目,并开始与我需要能够绘制一个矩形到具有透明度和文本的位图。
This is my first graphics based project and to begin with I need to be able to draw a rectangle onto a bitmap with transparency and text.
我不知道从哪里开始与此有关。我已经做了一些研究,但似乎无法找到一篇文章,让我到一个半透明的矩形添加到图像。
I'm not sure where to begin with this. I've done a little research but can't seem to find an article that will allow me to add a semi transparent rectangle to an image.
我将是我需要能够操纵的图像流。
What I will have is an image stream that I need to be able to manipulate.
可有人请点我在这个正确的方向?
Can someone please point me in the right direction for this?
与源站点将是巨大的,因为我从来没有做过任何GDI的工作。
A site with source would be great as I have never done any GDI work before.
推荐答案
您可以尝试这样的事情:
You can try something like this:
// Load the image (probably from your stream)
Image image = Image.FromFile( imagePath );
using (Graphics g = Graphics.FromImage(image))
{
// Modify the image using g here...
// Create a brush with an alpha value and use the g.FillRectangle function
}
image.Save( imageNewPath );
编辑:代码创建一个半透明度灰刷
the code to create a semi transparency gray brush
Color customColor = Color.FromArgb(50, Color.Gray);
SolidBrush shadowBrush = new SolidBrush(customColor);
g.FillRectangles(shadowBrush, new RectangleF[]{rectFToFill});
这篇关于我如何绘制一个矩形到图像具有透明度和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!