solo quería poner una selección en mi picturebox.image pero esto ha empeorado más que una pequeña situación molesta. Pensé en otro cuadro de imagen sobre el recuadro principal, pero me pareció un trabajo tan vago. Necesito saber si hay una manera de crear un área de selección (que será el área azul medio transparente) en un picturebox.image que voy a dibujar con el mouse y no debería cambiar la imagen en la que estoy trabajando.Cómo seleccionar un área en una PictureBox.Imagen con el mouse en C#
muestra:
// Start Rectangle
//
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Determine the initial rectangle coordinates...
RectStartPoint = e.Location;
Invalidate();
}
// Draw Rectangle
//
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
Point tempEndPoint = e.Location;
Rect =
new Rectangle(
Math.Min(RectStartPoint.X, tempEndPoint.X),
Math.Min(RectStartPoint.Y, tempEndPoint.Y),
Math.Abs(RectStartPoint.X - tempEndPoint.X),
Math.Abs(RectStartPoint.Y - tempEndPoint.Y));
Invalidate(Rect);
}
// Draw Area
//
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// Draw the rectangle...
if (pictureBox1.Image != null)
{
Brush brush = new SolidBrush(Color.FromArgb(128, 72, 145, 220));
e.Graphics.FillRectangle(brush, Rect);
}
}
¿Desea crear un cuadro de selección en una imagen en un cuadro de imagen? ¿Actuará el cuadro de selección lo mismo que hacer clic y arrastrar en el escritorio para crear un cuadrado azul transparente? – 3aw5TZetdf