I wrote this code:
private void ResizeImage()
{
SetImage(Image);
}
private void SetPen()
{
CreatePen(10,10,20,60);
}
private void CreatePen(int x, int y, int width, int height)
{
Rectangle = new Rectangle(x, y, width, height);
Pen = new Pen(Color.Crimson, 1);
(Image.CreateGraphics()).DrawRectangle(Pen, Rectangle);
Invalidate();
}
The problem is that the method Load() replaces image to rectangle. I’m doing image Cropper, where the user can not create new selection. The program creates the selection itself, the user can only move it.
In Paint event of PictureBox draw your rectangle: