8. IMAGE

3
IMAGE Especifique cuales son los tipos de ficheros que utiliza la clase Image. Desarróllalo a través de este medio. Clase base abstracta que proporciona funcionalidad para las clases Bitmap, Icon y Metafile Ejemplos IMAGE: Espacio de nombres: System.Drawing Ensamblado: System.Drawing (en System.Drawing.dll) 'VISUAL BASIC Private Sub ImageExampleForm_Paint _ (ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) _ Handles MyBase.Paint ' Create image. Dim newImage As Image = Image.FromFile("SampImag.jpg") ' Create Point for upper-left corner of image. Dim ulCorner As New Point(100, 100) ' Draw image to screen.

Transcript of 8. IMAGE

Page 1: 8. IMAGE

IMAGE

Especifique cuales son los tipos de ficheros que utiliza la clase Image. Desarróllalo a través de este medio.

Clase base abstracta que proporciona funcionalidad para las clases Bitmap, Icon y

Metafile

Ejemplos

IMAGE:

Espacio de nombres: System.Drawing

Ensamblado: System.Drawing (en System.Drawing.dll)

'VISUAL BASICPrivate Sub ImageExampleForm_Paint _ (ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) _ Handles MyBase.Paint

' Create image. Dim newImage As Image = Image.FromFile("SampImag.jpg")

' Create Point for upper-left corner of image. Dim ulCorner As New Point(100, 100)

' Draw image to screen. e.Graphics.DrawImage(newImage, ulCorner)End Sub

Page 2: 8. IMAGE

BITMAP

Espacio de nombres:  System.Drawing

Ensamblado:  System.Drawing (en System.Drawing.dll)

'VISUAL BASIC

Dim image1 As Bitmap

Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click

Try ' Retrieve the image. image1 = New Bitmap( _ "C:\Documents and Settings\All Users\Documents\My Music\music.bmp", _ True)

Dim x, y As Integer

' Loop through the images pixels to reset color. For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 Dim pixelColor As Color = image1.GetPixel(x, y) Dim newColor As Color = _ Color.FromArgb(pixelColor.R, 0, 0) image1.SetPixel(x, y, newColor) Next Next

' Set the PictureBox to display the image. PictureBox1.Image = image1

' Display the pixel format in Label1. Label1.Text = "Pixel format: " + image1.PixelFormat.ToString()

Catch ex As ArgumentException MessageBox.Show("There was an error." _

Page 3: 8. IMAGE

& "Check the path to the image file.") End TryEnd Sub