code_junkie

generate thumbnail with white border VB.net/C#?

Nov 10th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public Image AppendBorder(Image original, int borderWidth)
  2. {
  3. var borderColor = Color.White;
  4.  
  5. var newSize = new Size(
  6. original.Width + borderWidth * 2,
  7. original.Height + borderWidth * 2);
  8.  
  9. var img = new Bitmap(newSize.Width, newSize.Height);
  10. var g = Graphics.FromImage(img);
  11.  
  12. g.Clear(borderColor);
  13. g.DrawImage(original, new Point(borderWidth, borderWidth));
  14. g.Dispose();
  15.  
  16. return img;
  17. }
Add Comment
Please, Sign In to add comment