Rafał Developer
Rafał Developer

Reputation: 2055

Add box to picture C#

I would like to add to picture black box. How to do it?

enter image description here

  using (var image = Image.FromFile(imagePath))
  {
        using (var newImage = ScaleImage(image, 300, 400))
        {
              int width = newImage.Size.Width;
              int height = newImage.Size.Height;
              Graphics DrawingSurface = Graphics.FromImage(newImage);
              //graphics.DrawRectangle(); ????
              newImage.Save(imagePathDuzy);
        }
  }

Upvotes: 1

Views: 133

Answers (1)

Rune Grimstad
Rune Grimstad

Reputation: 36320

Use one of the FillRectangle methods on the Graphics type: http://msdn.microsoft.com/en-us/library/yysstebh.aspx

Probably something like this:

DrawingSurface.FillRectangle(new SolidBrush(Colors.Black), new Rectangle(0, height - 100, width, height));

This shold draw a black rectangle with 100px height at the bottom of the image.

Upvotes: 5

Related Questions