Leer en inglés

Compartir a través de


Image.Height Propiedad

Definición

Obtiene el alto en píxeles de Image.

C#
[System.ComponentModel.Browsable(false)]
public int Height { get; }

Valor de propiedad

Alto, en píxeles, de esta Image.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo construir un nuevo mapa de bits a partir de un archivo, usando los GetPixel métodos y SetPixel para volver a colorear la imagen. También usa las PixelFormat propiedades y Height .

Este ejemplo está diseñado para usarse con un Windows Forms que contiene , LabelPictureBoxy Button denominado Label1, PictureBox1y Button1, respectivamente. Pegue el código en el formulario y asocie el Button1_Click método al evento del Click botón.

C#
Bitmap image1;

private void Button1_Click(System.Object sender, System.EventArgs e)
{

    try
    {
        // Retrieve the image.
        image1 = new Bitmap(@"C:\Documents and Settings\All Users\" 
            + @"Documents\My Music\music.bmp", true);

        int x, y;

        // Loop through the images pixels to reset color.
        for(x=0; x<image1.Width; x++)
        {
            for(y=0; y<image1.Height; y++)
            {
                Color pixelColor = image1.GetPixel(x, y);
                Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
                image1.SetPixel(x, y, newColor);
            }
        }

        // Set the PictureBox to display the image.
        PictureBox1.Image = image1;

        // Display the pixel format in Label1.
        Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();
    }
    catch(ArgumentException)
    {
        MessageBox.Show("There was an error." +
            "Check the path to the image file.");
    }
}

Se aplica a

Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9