Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var recHeight = Convert.ToInt32(img.Height * 0.23);
  2. var recWidth = Convert.ToInt32(img.Width * 0.33);
  3.  
  4. var posH = Convert.ToInt32((img.Height - recHeight) / 2);
  5. var posW = Convert.ToInt32((img.Width - recWidth) / 2);
  6.  
  7. Rectangle rec = new Rectangle(posH, posW, recWidth, recHeight);
  8.  
  9. Bitmap bmp = new Bitmap(rec.Width, rec.Height);
  10. using (Graphics gph = Graphics.FromImage(img))
  11. {
  12. Pen pen = new Pen(Color.Red);
  13. gph.DrawRectangle(pen, rec);
  14. }
Add Comment
Please, Sign In to add comment