I have Bitmap image:
I draw rectangle on that image:
Bitmap myImage = new Bitmap("path");
using (Graphics gr = Graphics.FromImage(myImage))
{
Pen pen = new Pen(Color.Black, 2);
gr.DrawRectangle(pen, 100,100, 100, 200);
}
I want to fill the entire image with black color, except the rectangle. Like this:
Any idea how to implement it?
Click the Fill/Adjustment layer icon at the bottom of the Layers panel and select Solid Color. Pick a color from the Color Picker that appears. You can move the round selector to adjust the color, and then click OK. Tip: Drag the vertical slider on the rainbow-colored bar to view a different color range.
A simple ExcludeClip will do:
using (Graphics g = Graphics.FromImage(myImage)) {
g.ExcludeClip(new Rectangle(100, 100, 100, 200));
g.Clear(Color.Black);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With