添加框到图片C#

Raf*_*per 1 c#

我想添加图片黑盒子.怎么做?

在此输入图像描述

  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);
        }
  }
Run Code Online (Sandbox Code Playgroud)

Run*_*tad 5

使用Graphics类型上的一个FillRectangle方法:http://msdn.microsoft.com/en-us/library/yysstebh.aspx

可能是这样的:

DrawingSurface.FillRectangle(new SolidBrush(Colors.Black), new Rectangle(0, height - 100, width, height));
Run Code Online (Sandbox Code Playgroud)

此示例在图像底部绘制一个高度为100px的黑色矩形.