2013-05-30 100 views
1

我想添加到圖片黑色框。怎麼做?添加框到圖片C#

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); 
     } 
    } 

回答

5

使用的顯卡類型的FillRectangle方法之一:http://msdn.microsoft.com/en-us/library/yysstebh.aspx

大概是這樣的:

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

這shold繪製一個黑色矩形與100px的高度圖像的底部。

+0

我會檢查它。 –

+0

我會接受你的答案,但我必須等5分鐘。謝謝你的幫助。 –