Draw a Transparent Bar on an Image Using GDI+

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-size:x-small
I use Bob Powels image viewer code. He paints the Bitmap/Image directly onto a ScrollableControl something like this:
<span style="font-size:x-small
<span style="font-size:x-small <span style="font-size:x-small
<pre>protected override void OnPaint(PaintEventArgs e)
{
//Draw the .Tif image onto the control
e.Graphics.DrawImage(_image, new Rectangle(0, 0, this._image.Width, this._image.Height), 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel);
}
[/code]
<span style="font-size:x-small <span style="font-size:x-small
The user is doing data entry from the image, and he has to move his eyes down the page to the next row of data. To make this eye-movement easier, I allow his arrow keys to slide a "ruler" down the page (a highlight bar) drawn using simple code like this:
<span style="font-size:x-small <font size="2" style="font-size:x-small

</font><br/>
<pre>//Draw the highlight bar
e.Graphics.FillRectangle(Brushes.Lime, rect);
[/code]
<span style="font-size:x-small <span style="font-size:x-small
This code draws the highlight bar directly onto the image. The only thing I dont like is the solid color, because a transparent bar would enable the user to see any data underneath the highlight bar. I dont know how to draw a transparent bar (I still want
it be colored Lime and yet see-through). Is that possible? How?


View the full article
 
Back
Top