GRAFICOS

18- Copiar y Guardar Parte de una Imagen con Visual Basic (VB.NET).Graphics.

Se trata de una pequeña aplicacion que permite Copiar y Guardar Areas Seleccionadas de una Imagen.

Codigo:

Form1

Public Class Form1
    Dim DX, DY, ANCHO, ALTO As Integer
    Dim MICOLOR As Color
    Dim MIGROSOR As Integer
    Public Sub RECTANGULO()
        Dim MARCO As New Pen(MICOLOR, MIGROSOR)
        Dim CUADRADO As Graphics = PictureBox1.CreateGraphics
        CUADRADO.DrawRectangle(MARCO, DX, DY, ANCHO, ALTO)

    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
            ANCHO = PictureBox2.Width
            ALTO = PictureBox2.Height
            MICOLOR = Color.Red
            MIGROSOR = 1
            PictureBox1.Refresh()
            RECTANGULO()
        End If

    End Sub
   
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        PictureBox1.Refresh()
        DX += 10
      RECTANGULO()
    End Sub
 

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        PictureBox1.Refresh()
        DX -= 10
        RECTANGULO()
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        PictureBox1.Refresh()
        DY -= 10
        RECTANGULO()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        PictureBox1.Refresh()
        DY += 10
        RECTANGULO()
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim BITMAP1 As Bitmap = PictureBox1.Image
        Dim BITMAP2 As New Bitmap(ANCHO, ALTO)
        For Y = 0 To ALTO - 1
            For X = 0 To ANCHO - 1
                Dim BMCOLOR As Color = BITMAP1.GetPixel(X + DX, Y + DY)
                BITMAP2.SetPixel(X, Y, BMCOLOR)
            Next
        Next
        PictureBox2.Image = BITMAP2
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox2.Image.Save(SaveFileDialog1.FileName & ".jpg", Imaging.ImageFormat.Jpeg)
        End If
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

            MICOLOR = ColorDialog1.Color
            PictureBox1.Refresh()
            RECTANGULO()
        End If
    End Sub

    Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll

        MIGROSOR = TrackBar1.Value
        PictureBox1.Refresh()
        RECTANGULO()
    End Sub

    Private Sub TrackBar3_Scroll(sender As Object, e As EventArgs) Handles TrackBar3.Scroll

        ANCHO = TrackBar3.Value
        PictureBox1.Refresh()
        RECTANGULO()
        PictureBox2.Width = ANCHO
    End Sub

    Private Sub TrackBar2_Scroll(sender As Object, e As EventArgs) Handles TrackBar2.Scroll
        ALTO = TrackBar2.Value
        PictureBox1.Refresh()
        RECTANGULO()
        PictureBox2.Height = ALTO
    End Sub
End Class
 


 




06- Dibujo y Graficos, Imprimir, Visual Basic (VB.NET). Drawing & Graphics, Print
 Sexto video de la serie sobre las propiedades basicas de Dibujo y Graficos. En este video se ve  la aplicacion de Impresion del objeto Graphics.

 Codigo:

Form1

Imports System.Drawing.Printing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text

Public Class Form1

  
    Dim BM As Bitmap
    Dim DIBUJO As Graphics
    Dim LAPIZ As Brush
    Dim FUENTE As Font
    Dim MICOLOR As Color

    Private Sub BFUENTE_Click(sender As Object, e As EventArgs) Handles BFUENTE.Click
        FontDialog1.ShowDialog()
        FUENTE = FontDialog1.Font
        RichTextBox1.Font = FUENTE

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        RichTextBox1.Focus()
        FUENTE = RichTextBox1.Font
        MICOLOR = RichTextBox1.ForeColor
    End Sub
   
    Private Sub BCOLOR_Click(sender As Object, e As EventArgs) Handles BCOLOR.Click
        ColorDialog1.ShowDialog()
        MICOLOR = ColorDialog1.Color
        RichTextBox1.ForeColor = MICOLOR
    End Sub

    Private Sub BOPCIONESIMPRESION_Click(sender As Object, e As EventArgs) Handles BOPCIONESIMPRESION.Click

        If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PrintDocument1.Print()
        End If

    End Sub

    Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
        LAPIZ = New SolidBrush(MICOLOR)     
        DIBUJO = e.Graphics
        DIBUJO.TextRenderingHint = TextRenderingHint.AntiAlias
        DIBUJO.DrawString(RichTextBox1.Text, FUENTE, LAPIZ, 0, 0)

    End Sub

    Private Sub BCERRAR_Click(sender As Object, e As EventArgs) Handles BCERRAR.Click
        Close()
    End Sub

    Private Sub BMINIMIZAR_Click(sender As Object, e As EventArgs) Handles BMINIMIZAR.Click
        WindowState = FormWindowState.Minimized
    End Sub

  
End Class
 




17- Captura de Zonas de la Pantalla con Visual Basic (VB.NET).Graphics 

Se trata de una pequeña aplicacion que permite hacer Capturas de Zonas de la Pantalla, definidas por el usuario, ademas de Capturas de Pantalla Completa.

Codigo:

Form1:

 Imports System.Drawing.Imaging


Public Class Form1
 
    Public CARPETA As String
    Public CONTADOR As Integer = 1000000
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Button1.Enabled = False
            CARPETA = FolderBrowserDialog1.SelectedPath

            Button2.Visible = True
            Button3.Visible = True

         
        End If
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        Me.WindowState = FormWindowState.Minimized
        Threading.Thread.Sleep(300)
        'CAPTURA DE PANTALLA
        Dim BM As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
        Dim DIBUJO As Graphics = Graphics.FromImage(BM)
        DIBUJO.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size)
        DIBUJO.DrawImage(BM, 0, 0, BM.Width, BM.Height)
        BM.Save(CARPETA & "\" & CONTADOR & ".jpg", Imaging.ImageFormat.Jpeg)
        CONTADOR += 1
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ZONA.Opacity = 0.5
        ZONA.Show()
        Me.WindowState = FormWindowState.Minimized
    End Sub

End Class


ZONA:

Public Class ZONA

    Private Sub ZONA_Click(sender As Object, e As EventArgs) Handles Me.Click

        'Form1.Show()
        Me.Opacity = 0
        'CAPTURA DE ZONA
        Dim BM As Bitmap = New Bitmap(Me.Width - 20, Me.Height - 40)
        Dim DIBUJO As Graphics = Graphics.FromImage(BM)
        DIBUJO.CopyFromScreen(Me.Location.X + 10, Me.Location.Y + 40, 0, 0, Screen.PrimaryScreen.Bounds.Size)
        DIBUJO.DrawImage(BM, 0, 0, BM.Width, BM.Height)
        BM.Save(Form1.CARPETA & "\" & Form1.CONTADOR & ".jpg", Imaging.ImageFormat.Jpeg)
        Form1.CONTADOR += 1
    End Sub
End Class




16- Opciones para ProgressBar con Visual Basic (VB.NET). Graphics

Se trata de una pequeña aplicacion que permite crear personalizaciones de la Barra de Progreso de Visual Studio.



Codigo:

FORM1

 Imports System.Drawing.Drawing2D

Public Class Form1

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,
                                                                    ByVal lParam As Integer) As Integer
    Dim CONTADOR As Integer
    Dim MAXIMO As Integer
    Dim COLOR1 As Color
    Dim COLOR2 As Color
    Dim COLOR3 As Color
    Dim COLOR4 As Color
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ProgressBar1.Style = ProgressBarStyle.Blocks
        CONTADOR = 1
        Timer1.Start()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ProgressBar1.Style = ProgressBarStyle.Continuous
        CONTADOR = 1
        Timer1.Start()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ProgressBar1.Style = ProgressBarStyle.Marquee
        CONTADOR = 1
        Timer1.Start()
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If CONTADOR <= 100 Then
            ProgressBar1.Value = CONTADOR
            CONTADOR += 1
        Else
            Timer1.Stop()
            MsgBox("COMPLETADO")
        End If
    End Sub


    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            ProgressBar1.BackColor = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            ProgressBar1.ForeColor = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        SendMessage(ProgressBar1.Handle, 1040, 3, 0)
        CONTADOR = 1
        Timer1.Start()
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        SendMessage(ProgressBar1.Handle, 1040, 2, 0)
        CONTADOR = 1
        Timer1.Start()
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        If TextBox1.Text <> "" Or TextBox1.Text = 0 Then

            Try
                MAXIMO = CInt(TextBox1.Text)
                CONTADOR = 1
                Timer2.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("FALTA MAXIMO")
        End If
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.BackColor = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COLOR1 = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COLOR2 = ColorDialog1.Color
        End If
    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        If CONTADOR <= PictureBox1.Width Then
            Dim DIBUJO As Graphics = PictureBox1.CreateGraphics

            Dim RECTANGULO As New Rectangle(0, 0, CONTADOR, PictureBox1.Height)
            Dim GRADIENTELINEAL As LinearGradientBrush = New LinearGradientBrush(RECTANGULO, COLOR1, COLOR2, LinearGradientMode.Vertical)
            DIBUJO.FillRectangle(GRADIENTELINEAL, RECTANGULO)
            CONTADOR += 1
        Else
            Timer2.Stop()
            MsgBox("COMPLETADO")
        End If

      
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        PictureBox1.BackColor = Color.Gainsboro
        PictureBox2.BackColor = Color.Gainsboro
    End Sub

    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox2.BackColor = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COLOR3 = ColorDialog1.Color
        End If
    End Sub


    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COLOR4 = ColorDialog1.Color
        End If
    End Sub

    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        If TextBox2.Text <> "" Or TextBox2.Text = 0 Then

            Try
                MAXIMO = CInt(TextBox2.Text)
                CONTADOR = 1
                Timer3.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("FALTA MAXIMO")
        End If
    End Sub

    Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
        If CONTADOR <= PictureBox2.Height Then
            Dim DIBUJO As Graphics = PictureBox2.CreateGraphics

            Dim RECTANGULO As New Rectangle(0, PictureBox2.Height - CONTADOR, PictureBox2.Width, CONTADOR)



            Dim GRADIENTELINEAL As LinearGradientBrush = New LinearGradientBrush(RECTANGULO, COLOR3, COLOR4, LinearGradientMode.Horizontal)
            DIBUJO.FillRectangle(GRADIENTELINEAL, RECTANGULO)
            CONTADOR += 1
        Else
            Timer3.Stop()
            MsgBox("COMPLETADO")
        End If
    End Sub
End Class





09- Identificar la Imagen mas Parecida entre una Coleccion de Imagenes con VB.NET. Graphics 

Video Youtube


Codigo: 

Imports System.IO

Public Class Form1
    Dim FICHERO As String
    Dim ARCHIVOS As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
    Dim CONTADOR As Integer = 0
    Dim DICCIONARIO As New SortedDictionary(Of String, String)
    Dim ENUMERADOR As IDictionaryEnumerator
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CONTADOR = 0
        DICCIONARIO.Clear()
        OpenFileDialog1.ShowDialog()
        PictureBox1.Image = System.Drawing.Bitmap.FromFile(OpenFileDialog1.FileName)
    End Sub

    Public Sub COMPARACION()
        'COMPARACION DE PIXELES ENTRE PICTUREBOX1 Y PICTUREBOX2
        Dim BITMAP1 As Bitmap
        Dim BITMAP2 As Bitmap
        Dim ROJO As Integer = 0
        Dim VERDE As Integer = 0
        Dim AZUL As Integer = 0
        Dim X, Y As Integer

        BITMAP1 = PictureBox1.Image
        BITMAP2 = PictureBox2.Image
        For Y = 0 To BITMAP1.Height - 1 Step 10
            For X = 0 To BITMAP1.Width - 1 Step 10
                Dim MICOLOR1 As Color = BITMAP1.GetPixel(X, Y)
                Dim MICOLOR2 As Color = BITMAP2.GetPixel(X, Y)

                If Math.Abs(CInt(MICOLOR1.R) - CInt(MICOLOR2.R)) > 20 Then
                    ROJO = ROJO + 1

                End If
                If Math.Abs(CInt(MICOLOR1.G) - CInt(MICOLOR2.G)) > 20 Then
                    VERDE = VERDE + 1

                End If
                If Math.Abs(CInt(MICOLOR1.B) - CInt(MICOLOR2.B)) > 20 Then
                    AZUL = AZUL + 1

                End If
            Next
        Next
        Dim SUMA As Integer = ROJO + VERDE + AZUL
        Label1.Text = SUMA
        Label2.Text = ARCHIVOS(CONTADOR)

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        If CONTADOR <= ARCHIVOS.Count - 1 Then
            PictureBox2.Image = System.Drawing.Bitmap.FromFile(ARCHIVOS(CONTADOR))

            COMPARACION()
            Try
                DICCIONARIO.Add(Label1.Text, Label2.Text)
                ENUMERADOR = DICCIONARIO.GetEnumerator
                CONTADOR += 1
            Catch ex As Exception
                CONTADOR += 1
            End Try


        Else
            Timer1.Enabled = False
            MsgBox("NO HAY MAS IMAGENES")
            ENCONTRADO()
        End If
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


        If PictureBox1.Image Is Nothing Then
            MsgBox("CARGA LA IMAGEN1")
        Else
            CONTADOR = 0
            Timer1.Interval = 1000
            Timer1.Enabled = True
        End If
    End Sub

    Public Sub ENCONTRADO()
        Label3.Text = DICCIONARIO.Values.First
        ENUMERADOR = DICCIONARIO.GetEnumerator
        While ENUMERADOR.MoveNext
            If ENUMERADOR.Value = Label3.Text Then
                Label4.Text = ENUMERADOR.Key
            End If
        End While
        PictureBox2.Image = System.Drawing.Bitmap.FromFile(Label3.Text)
        Label1.Text = Label4.Text
        Label2.Text = Label3.Text
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        FolderBrowserDialog1.ShowDialog()
        FICHERO = FolderBrowserDialog1.SelectedPath
        ARCHIVOS = My.Computer.FileSystem.GetFiles(FICHERO)
        Button3.Text = ARCHIVOS.Count
    End Sub
End Class




15- Graficar Funciones Matematicas con Visual Basic (VB.NET). Graphics
Se trata de una pequeña aplicacion que permite hacer graficas de las principales funciones matemáticas.
Codigo:
Form1
Public Class Form1
    Dim VARX As New ArrayList
    Dim VARY As New ArrayList
    Dim ESCALA As Integer
    Dim CONTADOR As Integer = 0
    Dim DIBUJO As Graphics
    Dim BM As Bitmap
    Dim LAPIZ As New Pen(Color.Red, 5)
    Dim FUENTE As New Font("VERDANA", 8)
    Private Sub ButtonPLOT_Click(sender As Object, e As EventArgs) Handles ButtonPLOT.Click
      
        ALGEBRAICA()
        PINTASINVALORES()
       
    End Sub
    Private Sub ButtonVALORES_Click(sender As Object, e As EventArgs) Handles ButtonVALORES.Click
        ALGEBRAICA()
        PINTACONVALORES()
        DATOS.Show()
    End Sub
    Private Sub ButtonCTEPLOT_Click(sender As Object, e As EventArgs) Handles ButtonCTEPLOT.Click
        POTENCIACION()
        PINTASINVALORES()
    End Sub
    Private Sub ButtonCTEVALORES_Click(sender As Object, e As EventArgs) Handles ButtonCTEVALORES.Click
        POTENCIACION()
        PINTACONVALORES()
        DATOS.Show()
    End Sub
    Private Sub ButtonSENPLOT_Click(sender As Object, e As EventArgs) Handles ButtonSENPLOT.Click
        SENO()
        PINTASINVALORES()
    End Sub
    Private Sub ButtonSENVALORES_Click(sender As Object, e As EventArgs) Handles ButtonSENVALORES.Click
        SENO()
        PINTACONVALORES()
        DATOS.Show()
    End Sub
    Private Sub ButtonGUARDAR_Click(sender As Object, e As EventArgs) Handles ButtonGUARDAR.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image.Save(SaveFileDialog1.FileName & ".jpg", Imaging.ImageFormat.Jpeg)
        End If
    End Sub
    Public Sub PREVIOS()
        DATOS.ListView1.Items.Clear()
        VARX.Clear()
        VARY.Clear()
        ESCALA = CSng(TextBoxZOOM.Text)
        For I = -5 To 5 Step CSng(TextBoxPASO.Text)
            VARX.Add((I * ESCALA))
        Next
        CONTADOR = 0
    End Sub
    Public Sub ALGEBRAICA()
        PREVIOS()
        Try
            Dim COEF1 As Single = CSng(TextBoxCOEF1.Text)
            Dim EXP1 As Single = CSng(TextBoxEXP1.Text)
            Dim COEF2 As Single = CSng(TextBoxCOEF2.Text)
            Dim EXP2 As Single = CSng(TextBoxEXP2.Text)
            Dim COEF3 As Single = CSng(TextBoxCOEF3.Text)
            Dim EXP3 As Single = CSng(TextBoxEXP3.Text)
            For I = -5 To 5 Step CSng(TextBoxPASO.Text)
                Try
                    VARY.Add(Math.Pow((COEF1 * (Math.Pow(I, EXP1)) + (COEF2 * (Math.Pow(I, EXP2))) + COEF3), EXP3) * ESCALA)
                Catch ex As Exception
                End Try
                Dim listViewInformation(2) As String
                listViewInformation(0) = Math.Round(CSng(VARX(CONTADOR) / ESCALA), 2).ToString
                listViewInformation(1) = Math.Round(CSng(VARY(CONTADOR) / ESCALA), 2).ToString
                Dim item As ListViewItem = New ListViewItem(listViewInformation)
                DATOS.ListView1.Items.Add(item)
                CONTADOR += 1
            Next
        Catch ex As Exception
            MsgBox("REVISA TUS VALORES INICIALES")
        End Try
    End Sub
    Public Sub POTENCIACION()
        PREVIOS()
        Try
            Dim CONSTANTE As Single = CSng(TextBoxCTE.Text)
            Dim CTECOEF As Single = CSng(TextBoxCTECOEF.Text)
            Dim CTEEXP As Single = CSng(TextBoxCTEEXP.Text)
            Dim PASO As Single = CSng(TextBoxPASO.Text)
            For I = -5 To 5 Step PASO
                Try
                    VARY.Add(Math.Pow(CONSTANTE, CTECOEF * Math.Pow(I, CTEEXP)) * ESCALA)
                Catch ex As Exception
                End Try
                Dim listViewInformation(2) As String
                listViewInformation(0) = Math.Round(CSng(VARX(CONTADOR) / ESCALA), 2).ToString
                listViewInformation(1) = Math.Round(CSng(VARY(CONTADOR) / ESCALA), 2).ToString
                Dim item As ListViewItem = New ListViewItem(listViewInformation)
                DATOS.ListView1.Items.Add(item)
                CONTADOR += 1
            Next
        Catch ex As Exception
            MsgBox("REVISA TUS VALORES INICIALES")
        End Try
    End Sub
    Public Sub SENO()
        PREVIOS()
        Try
            Dim COEFICIENTE As Single = CSng(TextBoxSENCOEF.Text)
            Dim SENXCOEF As Single = CSng(TextBoxSENXCOEF.Text)
            Dim SENXEXP As Single = CSng(TextBoxSENXEXP.Text)
            Dim SENTOEXP As Single = CSng(TextBoxSENTOEXP.Text)
            Dim PASO As Single = CSng(TextBoxPASO.Text)
            For I = -5 To 5 Step PASO
                Try
                    VARY.Add(COEFICIENTE * Math.Sin(Math.Pow(SENXCOEF * Math.Pow(I, SENXEXP), SENTOEXP)) * ESCALA)
                Catch ex As Exception
                End Try
                Dim listViewInformation(2) As String
                listViewInformation(0) = Math.Round(CSng(VARX(CONTADOR) / ESCALA), 2).ToString
                listViewInformation(1) = Math.Round(CSng(VARY(CONTADOR) / ESCALA), 2).ToString
                Dim item As ListViewItem = New ListViewItem(listViewInformation)
                DATOS.ListView1.Items.Add(item)
                CONTADOR += 1
            Next
        Catch ex As Exception
            MsgBox("REVISA TUS VALORES INICIALES")
        End Try

    End Sub
    Public Sub PINTA()
        BM = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        DIBUJO = Graphics.FromImage(BM)
        DIBUJO.Clear(Color.White)
        DIBUJO.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        DIBUJO.DrawLine(Pens.LightGray, CSng(PictureBox1.Width / 2), 0, CSng(PictureBox1.Width / 2), PictureBox1.Height)
        DIBUJO.DrawLine(Pens.LightGray, 0, CSng(PictureBox1.Height / 2), PictureBox1.Width, CSng(PictureBox1.Height / 2))
        DIBUJO.TranslateTransform(CSng(PictureBox1.Width / 2), CSng(PictureBox1.Height / 2))
    End Sub
    Public Sub PINTASINVALORES()
      
        PINTA()
        For I = 0 To VARX.Count - 2
            Try
                DIBUJO.DrawLine(LAPIZ, CSng(VARX(I)), CSng(VARY(I)) * -1, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)
              
            Catch ex As Exception
            End Try
        Next
        PictureBox1.Image = BM
    End Sub
    Public Sub PINTACONVALORES()
       
        PINTA()
        For I = 0 To VARX.Count - 2
            Try
                DIBUJO.DrawLine(LAPIZ, CSng(VARX(I)), CSng(VARY(I)) * -1, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)
                DIBUJO.DrawString("{" & Math.Round((VARX(I + 1) / ESCALA), 2) & " : " & Math.Round((VARY(I + 1) / ESCALA), 2) & "}",
                                  FUENTE, Brushes.Blue, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)
            Catch ex As Exception
            End Try
        Next
        PictureBox1.Image = BM
    End Sub
     
End Class
14- Rotacion de una Imagen con Visual Basic (VB.NET). Graphics

Se trata de una pequeña aplicacion para tratar el tema de la rotacion de imagenes. Este tema ya fue tratado en algun proyecto anterior, pero algunas personas no lo localizan. Asi que hemos hecho una aplicacion especifica.


Codigo:
Form1
Public Class Form1
    Dim BM As Bitmap
    Dim DIBUJO As Graphics
    Dim ANGULO As Single
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      
            ANGULO = 0
        Timer1.Interval = 500
            Timer1.Enabled = True
      
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        BM = New Bitmap(PictureBox1.Image)
        Dim BM2 As Bitmap = New Bitmap(PictureBox2.Width, PictureBox2.Height)
        DIBUJO = Graphics.FromImage(BM2)
        DIBUJO.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        DIBUJO.TranslateTransform(CInt(PictureBox2.Width / 2), CInt(PictureBox2.Height /
2))
        DIBUJO.RotateTransform(ANGULO)
        DIBUJO.DrawImage(BM, 0, 0, PictureBox1.Width, PictureBox1.Height)
        DIBUJO.ResetTransform()
        PictureBox2.Image = BM2
        ANGULO += 5
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Timer1.Enabled = False
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox2.Image.Save(SaveFileDialog1.FileName & ".JPG",
Imaging.ImageFormat.Jpeg)
        End If
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Timer1.Enabled = True
    End Sub
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles
PictureBox1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
           
        End If
    End Sub
End Class
13- Reloj " Analogico " con Visual Basic (VB.NET). Graphics

Se trata de una pequeña aplicación que crea un Reloj, aparentemente, Analogico. Solo sirve como ejercicio didáctico de temas relacionados con Graphics. No creo que a nadie se le ocurra usarlo para otra cosa.


Codigo:

Form1
Imports System.Drawing.Drawing2D
Public Class Form1
    Dim FLAG As Boolean = False
    Dim ANGULOSEGUNDOS As Integer
    Dim ANGULOMINUTOS As Integer
    Dim ANGULOHORAS As Integer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TOMA LA FECHA DEL SISTEMA
        Label13.Text = Date.Today.ToShortDateString
        'FORMA CIRCULAR DEL FORMULARIO
        Dim ELIPSE As New GraphicsPath()
        Dim R As New Rectangle(0, 0, Me.Height, Me.Height)
        ELIPSE.AddEllipse(R)
        Me.Region = New Region(ELIPSE)
        'FORMA CIRCULAR DEL PICTUREBOX
        Dim ELIPSE1 As New GraphicsPath()
        Dim R1 As New Rectangle(0, 0, PictureBox1.Height, PictureBox1.Height)
        ELIPSE1.AddEllipse(R1)
        PictureBox1.Region = New Region(ELIPSE1)
        'DEFINE LAS VARIABLES
        ANGULOSEGUNDOS = 230 + (Date.Now.Second * 6) 'AJUSTE+ 360º/60 SEGUNDOS
        ANGULOMINUTOS = 230 + (Date.Now.Minute * 6) 'AJUSTE+ 360º/60 MINUTOS
        If Date.Now.Minute > 30 Then 'AVANCE DE LA HORA AL REBASAR LOS 30 MINUTOS
            ANGULOHORAS = 245 + (Date.Now.Hour * 30) ' AJUSTE+ 360º/12 HORAS
        Else 'AVANCE DE LA HORA NORMAL
            ANGULOHORAS = 230 + (Date.Now.Hour * 30) ' AJUSTE+ 360º/12 HORAS
        End If
        'DIBUJA LAS MANECILLAS
        PINTA()
        'PONE EN MARCHA EL RELOJ CON INTERVALO DE 1 SEGUNDO
        Timer1.Interval = 1000
        Timer1.Enabled = True
      
    End Sub
  
    Public Sub PINTA()
        'DEFINE LAS VARIABLES DE GRAPHICS
        Dim BM As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        Dim DIBUJO As Graphics = Graphics.FromImage(BM)
        'QUEREMOS LINEAS SUAVES
        DIBUJO.SmoothingMode = SmoothingMode.AntiAlias
        'DIBUJA LA MANECILLA DE SEGUNDOS
        Dim SEGUNDOS As New Pen(Brushes.Red, 3)
        SEGUNDOS.SetLineCap(0, LineCap.DiamondAnchor, DashCap.Triangle)
        Dim RADIOSEGUNDOS As Integer = CInt(PictureBox1.Width / 2) - 35
        DIBUJO.TranslateTransform(100, 100)
        DIBUJO.RotateTransform(ANGULOSEGUNDOS)
        DIBUJO.DrawLine(SEGUNDOS, 0, 0, RADIOSEGUNDOS, RADIOSEGUNDOS)
        DIBUJO.ResetTransform()
        'DIBUJA LA MANECILLA DE MINUTOS
        Dim MINUTOS As New Pen(Brushes.Black, 5)
        MINUTOS.SetLineCap(0, LineCap.DiamondAnchor, DashCap.Triangle)
        Dim RADIOMINUTOS As Integer = CInt(PictureBox1.Width / 2) - 40
        DIBUJO.TranslateTransform(100, 100)
        DIBUJO.RotateTransform(ANGULOMINUTOS)
        DIBUJO.DrawLine(MINUTOS, 0, 0, RADIOMINUTOS, RADIOMINUTOS)
        DIBUJO.ResetTransform()
        'DIBUJA LA MANECILLA DE HORAS
        Dim HORAS As New Pen(Brushes.Black, 5)
        HORAS.SetLineCap(0, LineCap.DiamondAnchor, DashCap.Triangle)
        Dim RADIOHORAS As Integer = CInt(PictureBox1.Width / 2) - 50
        DIBUJO.TranslateTransform(100, 100)
        DIBUJO.RotateTransform(ANGULOHORAS)
        DIBUJO.DrawLine(HORAS, 0, 0, RADIOHORAS, RADIOHORAS)
        DIBUJO.ResetTransform()
        'TAPA LA UNION DE LAS 3 MANECILLAS
        DIBUJO.DrawEllipse(Pens.Black, CInt(PictureBox1.Width / 2) - 15, CInt
(PictureBox1.Height / 2) - 15, 30, 30)
        DIBUJO.FillEllipse(Brushes.PaleGoldenrod, CInt(PictureBox1.Width / 2) - 15, CInt
(PictureBox1.Height / 2) - 15, 30, 30)
        'PRESENTALO EN EL PICTUREBOX
        PictureBox1.Image = BM
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        'CADA SEGUNDO:
        '
        'TOMA LA FECHA DEL SISTEMA
        Label13.Text = Date.Today.ToShortDateString
        'TOMA LOS SEGUNDOS DEL SISTEMA Y CONVIERTELO EN ANGULO
        ANGULOSEGUNDOS = 230 + (Date.Now.Second * 6)
        'TOMA LOS MINUTOS DEL SISTEMA Y CONVIERTELO EN ANGULO
        ANGULOMINUTOS = 230 + (Date.Now.Minute * 6)
        'SI LOS MINUTOS SON MAS DE 30 AVANZA UN POCO LA MANECILLA DE LAS HORAS
        If Date.Now.Minute > 30 Then
            'TOMA LAS HORAS DEL SISTEMA Y CONVIERTELAS EN ANGULO AJUSTADO
            ANGULOHORAS = 245 + (Date.Now.Hour * 30)
        Else
            'TOMA LAS HORAS DEL SISTEMA Y CONVIERTELAS EN ANGULO
            ANGULOHORAS = 230 + (Date.Now.Hour * 30)
        End If
        'REPITE LA OPERACION DE DIBUJAR TODOS LOS ELEMENTOS
        PINTA()
    End Sub
    Private Sub PictureBox1_DoubleClick(sender As Object, e As EventArgs) Handles
PictureBox1.DoubleClick
        'AL HACER DOBLE CLICK SOBRE EL PICTUREBOX, CIERRATE
        Me.Close()
    End Sub
    '+++++++   MOVIMIENTO DEL RELOJ ++++++++++++++++++++++++++++++++++++
+++++++++++++++++++
    Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles
Me.MouseDown
        FLAG = True
    End Sub
    Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles
Me.MouseMove
        If FLAG = True Then
            Me.Location = New Point(Me.Location.X + e.X, Me.Location.Y + e.Y)
        End If
    End Sub
    Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles
Me.MouseUp
        FLAG = False
    End Sub
    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++
End Class


12- Diferencias Entre Imagenes, " Esteganografia" con Visual Basic (VB.NET). Graphics
Se trata de una pequeña aplicación que permite localizar las diferencias entre dos imágenes a nivel de pixel. También permite guardar y leer texto oculto.
Codigo:
Form1
Public Class Form1
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles
PictureBox1.Click
        PictureBox3.Image = Nothing
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles
PictureBox2.Click
        PictureBox3.Image = Nothing
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox2.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox3.Image = Nothing
        Dim CONTADOR As Integer = 0
        Dim BM1 As Bitmap = New Bitmap(PictureBox1.Image)
        Dim BM2 As Bitmap = New Bitmap(PictureBox2.Image)
        Dim BM3 As Bitmap = New Bitmap(PictureBox3.Width, PictureBox3.Height)
        For J = 0 To BM1.Height - 1
            For I = 0 To BM1.Width - 1
                If BM1.GetPixel(I, J) <> BM2.GetPixel(I, J) Then
                    Try
                        BM3.SetPixel(I, J, Color.Red)
                        CONTADOR += 1
                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try

                End If
            Next
        Next
        PictureBox3.Image = BM3
        MsgBox(CONTADOR & " PIXELES DIFERENTES")
    End Sub
  
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        PictureBox3.Image = Nothing
        Dim MICOLOR As Color = Color.FromArgb(255, 0, 0, 1)
        Dim MIBRUSH As New SolidBrush(MICOLOR)
        Dim FRASE As String = InputBox("ESCRIBE LA FRASE")
        Dim BM As Bitmap = New Bitmap(PictureBox1.Image)
        Dim DIBUJO As Graphics = Graphics.FromImage(BM)
        Dim FUENTE As New Font("VERDANA", 20)
        DIBUJO.DrawString(FRASE, FUENTE, MIBRUSH, 0, 0)
        PictureBox1.Image = BM
       
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        PictureBox3.Image = Nothing
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image.Save(SaveFileDialog1.FileName & ".BMP",
Imaging.ImageFormat.Bmp)
        End If
    End Sub
End Class
11- Composicion (Collage) de Imagenes con Visual Basic (VB.NET).Graphics

Se trata de una pequeña aplicacion que permite crear imagenes compuestas de otras imagenes (Collage)


Codigo:

Form1


Public Class Form1
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox2.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox3.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox4.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox5.Image = Bitmap.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub PictureBoxLIENZO_Click(sender As Object, e As EventArgs) Handles PictureBoxLIENZO.Click
        If PictureBox5.Image IsNot Nothing Then
            If PictureBox1.Image IsNot Nothing And PictureBox2.Image IsNot Nothing And PictureBox3.Image IsNot Nothing And PictureBox4.Image IsNot Nothing Then
                CINCO()
            Else
                MsgBox("FALTAN IMAGENES POR COLOCAR")
            End If
        Else
            If PictureBox1.Image IsNot Nothing And PictureBox2.Image IsNot Nothing And PictureBox3.Image IsNot Nothing And PictureBox4.Image IsNot Nothing Then
                CUATRO()
            Else
                MsgBox("FALTAN IMAGENES POR COLOCAR")
            End If
        End If
       
    End Sub
    Private Sub ButtonGUARDAR_Click(sender As Object, e As EventArgs) Handles ButtonGUARDAR.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBoxLIENZO.Image.Save(SaveFileDialog1.FileName & ".JPG", Imaging.ImageFormat.Jpeg)
        End If
    End Sub
    Private Sub ButtonCENTRO_Click(sender As Object, e As EventArgs) Handles ButtonCENTRO.Click
        PictureBox5.Visible = True
    End Sub
    Private Sub ButtonBORRAR_Click(sender As Object, e As EventArgs) Handles ButtonBORRAR.Click
        PictureBoxLIENZO.Image = Nothing
    End Sub
    Public Sub CUATRO()
        Dim BM1 As New Bitmap(PictureBox1.Image)
        Dim BM2 As New Bitmap(PictureBox2.Image)
        Dim BM3 As New Bitmap(PictureBox3.Image)
        Dim BM4 As New Bitmap(PictureBox4.Image)

        Dim ANCHO As Integer = Math.Max(BM1.Width + BM2.Width, BM3.Width + BM4.Width)
        Dim ALTO As Integer = Math.Max(BM1.Height + BM2.Height, BM3.Height + BM4.Height)
        Dim TAMAÑO As New Bitmap(ANCHO, ALTO)
        Dim DIBUJO As Graphics = Graphics.FromImage(TAMAÑO)
        DIBUJO.DrawImage(BM1, 0, 0, BM1.Width, BM1.Height)
        DIBUJO.DrawImage(BM2, BM1.Width, 0, BM2.Width, BM2.Height)
        DIBUJO.DrawImage(BM3, 0, BM1.Height, BM3.Width, BM3.Height)
        DIBUJO.DrawImage(BM4, BM3.Width, BM2.Height, BM4.Width, BM4.Height)
        PictureBoxLIENZO.Image = TAMAÑO
    End Sub
    Public Sub CINCO()
        Dim BM1 As New Bitmap(PictureBox1.Image)
        Dim BM2 As New Bitmap(PictureBox2.Image)
        Dim BM3 As New Bitmap(PictureBox3.Image)
        Dim BM4 As New Bitmap(PictureBox4.Image)
        Dim BM5 As New Bitmap(PictureBox5.Image)

        Dim ANCHO As Integer = Math.Max(BM1.Width + BM2.Width, BM3.Width + BM4.Width)
        Dim ALTO As Integer = Math.Max(BM1.Height + BM2.Height, BM3.Height + BM4.Height)
        Dim TAMAÑO As New Bitmap(ANCHO, ALTO)
        Dim DIBUJO As Graphics = Graphics.FromImage(TAMAÑO)
        DIBUJO.DrawImage(BM1, 0, 0, BM1.Width, BM1.Height)
        DIBUJO.DrawImage(BM2, BM1.Width, 0, BM2.Width, BM2.Height)
        DIBUJO.DrawImage(BM3, 0, BM1.Height, BM3.Width, BM3.Height)
        DIBUJO.DrawImage(BM4, BM3.Width, BM2.Height, BM4.Width, BM4.Height)
        DIBUJO.DrawImage(BM5, CInt(BM1.Width / 2), CInt(BM1.Height / 2), BM5.Width, BM5.Height)
        PictureBoxLIENZO.Image = TAMAÑO
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox5.Image = Nothing
    End Sub
End Class

Dibujar, Pintar y Calcar en Visual Basic (VB.NET) (Graphics)
Se trata de una pequeña aplicacion que permite dibujar y pintar. Tambien  permite calcar cualquier imagen que tengamos en el ordenador. El trabajo realizado puede ser guardado en la carpeta que elijamos.
Codigo:
Form1
Public Class Form1
    Private Sub UNO_Click(sender As System.Object, e As System.EventArgs) Handles UNO.Click
        ORIGINAL.Image = UNO.Image
        Button1.Visible = True
    End Sub
    Private Sub DOS_Click(sender As System.Object, e As System.EventArgs) Handles DOS.Click
        ORIGINAL.Image = DOS.Image
        Button1.Visible = True
    End Sub
   
    Private Sub TRES_Click(sender As Object, e As EventArgs) Handles TRES.Click
        ORIGINAL.Image = TRES.Image
        Button1.Visible = True
    End Sub
   
    Private Sub CUATRO_Click(sender As Object, e As EventArgs) Handles CUATRO.Click
        ORIGINAL.Image = CUATRO.Image
        Button1.Visible = True
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CALCO.Opacity = 0.5
        CALCO.Show()
        AUXILIAR.Show()
        AUXILIAR.Height = CALCO.Height
        AUXILIAR.Location = New Point(CALCO.Width - AUXILIAR.Width, 0)
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Close()
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MsgBox("ELIGE EL DIBUJO A CALCAR Y PULSA CALCAR O PULSA DIBUJO LIBRE")
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        OF1.ShowDialog()
        ORIGINAL.Image = System.Drawing.Bitmap.FromFile(OF1.FileName)
        Button1.Visible = True
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ORIGINAL.Image = Nothing
        CALCO.Opacity = 0.99
        CALCO.Show()
        AUXILIAR.Show()
        AUXILIAR.Height = CALCO.Height
        AUXILIAR.Location = New Point(CALCO.Width - AUXILIAR.Width, 0)
    End Sub
End Class
Auxiliar
Imports System.Drawing.Imaging
Public Class AUXILIAR
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If CALCO.Opacity < 0.2 Then
            MsgBox("LIMITE")
        Else
            CALCO.Opacity -= 0.1
        End If
    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        If CALCO.Opacity > 0.9 Then
            MsgBox("LIMITE")
        Else
            CALCO.Opacity += 0.1
        End If
    End Sub
    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Close()
        CALCO.Close()
    End Sub
    Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        ColorDialog1.ShowDialog()
        Label1.BackColor = ColorDialog1.Color
    End Sub
    Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
        ColorDialog1.Color = Color.White
        Label1.BackColor = ColorDialog1.Color
    End Sub


    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        ' Save the picture.
        SF1.ShowDialog()


        Dim bm As Bitmap = GetFormImage()
        bm.Save(SF1.FileName & ".JPG")
        MsgBox("IMAGEN GUARDADA COMO: " & SF1.FileName)
    End Sub
    'CONVIERTE EL FORMULARIO EN UNA IMAGEN
    Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _
        hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _
        nYDest As Integer, ByVal nWidth As Integer, ByVal _
        nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _
        As Integer, ByVal nYSrc As Integer, ByVal dwRop As  _
        System.Int32) As Boolean
    Private Const SRCCOPY As Integer = &HCC0020
    Private Function GetFormImage() As Bitmap
        ' Get this form's Graphics object.
        Dim CALCO_gr As Graphics = CALCO.CreateGraphics
        ' Make a Bitmap to hold the image.
        Dim bm As New Bitmap(CALCO.ClientSize.Width, _
            CALCO.ClientSize.Height, CALCO_gr)
        Dim bm_gr As Graphics = Graphics.FromImage(bm)
        Dim bm_hdc As IntPtr = bm_gr.GetHdc
        ' Get the form's hDC. We must do this after
        ' creating the new Bitmap, which uses CALCO_gr.
        Dim CALCO_hdc As IntPtr = CALCO_gr.GetHdc
        ' BitBlt the form's image onto the Bitmap.
        BitBlt(bm_hdc, 0, 0, CALCO.ClientSize.Width, _
            CALCO.ClientSize.Height, _
            CALCO_hdc, 0, 0, SRCCOPY)
        CALCO_gr.ReleaseHdc(CALCO_hdc)
        bm_gr.ReleaseHdc(bm_hdc)

        ' Return the result.
        Return bm
    End Function

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        CALCO.PictureBox1.Refresh()
    End Sub
End Class


Calco


Public Class CALCO
    Dim BANDERA As Boolean = False
    Dim COLOR As SolidBrush
    Dim GROSOR As Integer

    Private Sub PictureBox1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        BANDERA = True
    End Sub
    Private Sub PictureBox1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        COLOR = New System.Drawing.SolidBrush(AUXILIAR.ColorDialog1.Color)
        GROSOR = AUXILIAR.PINCEL.Value
        If BANDERA = True Then
            PictureBox1.CreateGraphics.FillEllipse(COLOR, e.X, e.Y, GROSOR, GROSOR)
        End If
    End Sub
    Private Sub PictureBox1_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
        BANDERA = False
    End Sub

 
End Class







10- Grafico de Barras con Visual Basic (VB.NET). Graphics


Codigo:

Form1

Imports System.Drawing.Drawing2D
Public Class Form1
    Dim SEGUNDOS As Integer
    Dim COGRAFICO As Color
    Dim GROSORGRAFICO As Integer
    Dim CONUMEROS As Color
    Dim GROSORNUMEROS As Integer
    Dim COLEYENDA As Color
    Dim GROSORLEYENDA As Integer
    Dim BM As Bitmap
    Dim DIBUJO As Graphics
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        COGRAFICO = Color.Lime
        GROSORGRAFICO = 3
        CONUMEROS = Color.Lime
        GROSORNUMEROS = 15
        CONUMEROS = Color.Lime
        GROSORNUMEROS = 15
        COLEYENDA = Color.Lime
        GROSORLEYENDA = 15
        SEGUNDOS = 0
        BM = New Bitmap(PictureBox1.Width, PictureBox1.Height)
        DIBUJO = Graphics.FromImage(BM)
    End Sub
    Private Sub ButtonINICIAR_Click(sender As Object, e As EventArgs) Handles ButtonINICIAR.Click
        TextBox1.Visible = False
      
        Timer1.Enabled = True
    End Sub
    Private Sub ButtonPARAR_Click(sender As Object, e As EventArgs) Handles ButtonPARAR.Click
        Timer1.Enabled = False
    End Sub
    Private Sub ButtonCOGRAFICO_Click(sender As Object, e As EventArgs) Handles ButtonCOGRAFICO.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COGRAFICO = ColorDialog1.Color
        End If
    End Sub
    Private Sub ButtonCONUMEROS_Click(sender As Object, e As EventArgs) Handles ButtonCONUMEROS.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            CONUMEROS = ColorDialog1.Color
        End If
    End Sub
    Private Sub ButtonLEYENDA_Click(sender As Object, e As EventArgs) Handles ButtonLEYENDA.Click
        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            COLEYENDA = ColorDialog1.Color
        End If
    End Sub
    Private Sub ButtonGUARDAR_Click(sender As Object, e As EventArgs) Handles ButtonGUARDAR.Click
       
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Try
                BM.Save(SaveFileDialog1.FileName & ".JPG", Imaging.ImageFormat.Jpeg)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub
    Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
        GROSORGRAFICO = TrackBar1.Value
    End Sub
    Private Sub TrackBar2_Scroll(sender As Object, e As EventArgs) Handles TrackBar2.Scroll
        GROSORNUMEROS = TrackBar2.Value
    End Sub
    Private Sub TrackBar3_Scroll(sender As Object, e As EventArgs) Handles TrackBar3.Scroll
        GROSORLEYENDA = TrackBar3.Value
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        SEGUNDOS += 50 'ESPACIO EN X
        'RANDOM
        Dim generator As New Random
        Dim randomValue As Integer
        randomValue = generator.Next(20, PictureBox1.Height - 100)
        'DIBUJA LEYENDA
        Dim drawFormatLEYENDA As New StringFormat()
        Dim drawFontLEYENDA As New System.Drawing.Font("Arial", GROSORLEYENDA)
        Dim drawBrushLEYENDA As New SolidBrush(COLEYENDA)
        DIBUJO.DrawString(TextBox1.Text, drawFontLEYENDA, drawBrushLEYENDA, _
         CInt((PictureBox1.Width / 2) - (TextBox1.Text.Length * TextBox1.Font.Size / 2)), TextBox1.Font.Size, drawFormatLEYENDA)
    
        'DIBUJA NUMEROS
        Dim drawFormat As New StringFormat()
        Dim drawFont As New System.Drawing.Font("Arial", GROSORNUMEROS)
        Dim drawBrush As New SolidBrush(CONUMEROS)
        DIBUJO.DrawString(randomValue, drawFont, drawBrush, _
            SEGUNDOS, PictureBox1.Height - randomValue, drawFormat)
        'DIBUJA GRAFICO
        Dim LAPIZ As New Pen(COGRAFICO, GROSORGRAFICO)
        DIBUJO.DrawLine(LAPIZ, 0, PictureBox1.Height - 10, SEGUNDOS, PictureBox1.Height - 10)
        DIBUJO.DrawLine(LAPIZ, SEGUNDOS, PictureBox1.Height - 10, SEGUNDOS, PictureBox1.Height - randomValue)
        DIBUJO.DrawImage(BM, 0, 0, PictureBox1.Width, PictureBox1.Height)
        PictureBox1.Image = BM
        'REFRESCA GRAFICO
        If SEGUNDOS > PictureBox1.Width Then
            BM = New Bitmap(PictureBox1.Width, PictureBox1.Height)
            DIBUJO = Graphics.FromImage(BM)
            SEGUNDOS = 0
        End If
    End Sub
End Class




07-Dibujo y Graficos, Cambiar la Forma de los Controles con Visual Basic (VB.NET)
CODIGO:
Imports System.Drawing.Drawing2D
Public Class Form1
    Dim FLAG As Boolean = False
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ELIPSE As New GraphicsPath()
        Dim R As New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height)
        ELIPSE.AddEllipse(R)
        PictureBox1.Region = New Region(ELIPSE)
        Dim ELIPSE1 As New GraphicsPath()
        Dim R1 As New Rectangle(0, 0, Label1.Width, Label1.Height)
        ELIPSE1.AddEllipse(R1)
        Label1.Region = New Region(ELIPSE1)

        Dim ELIPSE2 As New GraphicsPath()
        Dim R2 As New Rectangle(0, 0, Panel1.Width, Panel1.Height)
        ELIPSE2.AddEllipse(R2)
        Panel1.Region = New Region(ELIPSE2)
   
    End Sub
   
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim TRIANGULO As New GraphicsPath()
        Dim PUNTOS As Point() = {New Point(CInt(PictureBox1.Width / 2), 0), New Point(0, PictureBox1.Height), New Point(PictureBox1.Width, PictureBox1.Height)}
        TRIANGULO.AddPolygon(PUNTOS)
        PictureBox1.Region = New Region(TRIANGULO)
        Dim TRIANGULO1 As New GraphicsPath()
        Dim PUNTOS1 As Point() = {New Point(CInt(Label1.Width / 2), 0), New Point(0, Label1.Height), New Point(Label1.Width, Label1.Height)}
        TRIANGULO1.AddPolygon(PUNTOS1)
        Label1.Region = New Region(TRIANGULO1)
        Dim TRIANGULO2 As New GraphicsPath()
        Dim PUNTOS2 As Point() = {New Point(CInt(Panel1.Width / 2), 0), New Point(0, Panel1.Height), New Point(Panel1.Width, Panel1.Height)}
        TRIANGULO2.AddPolygon(PUNTOS2)
        Panel1.Region = New Region(TRIANGULO2)
       
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ColorDialog1.ShowDialog()
        Panel1.BackColor = ColorDialog1.Color
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim POLIGONO As New GraphicsPath()
        Dim PUNTOS As Point() = {New Point(CInt(PictureBox1.Width / 3), 0),
                                 New Point(CInt(PictureBox1.Width / 3) * 2, 0),
                                 New Point(PictureBox1.Width, CInt(PictureBox1.Height / 2)),
                                 New Point(CInt(PictureBox1.Width / 3) * 2, PictureBox1.Height),
                                 New Point(CInt(PictureBox1.Width / 3), PictureBox1.Height),
                                 New Point(0, CInt(PictureBox1.Height / 2)),
                                 New Point(CInt(PictureBox1.Width / 3), 0)}
        POLIGONO.AddPolygon(PUNTOS)
        PictureBox1.Region = New Region(POLIGONO)
        Dim POLIGONO1 As New GraphicsPath()
        Dim PUNTOS1 As Point() = {New Point(CInt(Label1.Width / 3), 0),
                                 New Point(CInt(Label1.Width / 3) * 2, 0),
                                 New Point(Label1.Width, CInt(Label1.Height / 2)),
                                 New Point(CInt(Label1.Width / 3) * 2, Label1.Height),
                                 New Point(CInt(Label1.Width / 3), Label1.Height),
                                 New Point(0, CInt(Label1.Height / 2)),
                                 New Point(CInt(Label1.Width / 3), 0)}
        POLIGONO1.AddPolygon(PUNTOS1)
        Label1.Region = New Region(POLIGONO1)
        Dim POLIGONO2 As New GraphicsPath()
        Dim PUNTOS2 As Point() = {New Point(CInt(Panel1.Width / 3), 0),
                                 New Point(CInt(Panel1.Width / 3) * 2, 0),
                                 New Point(Panel1.Width, CInt(Panel1.Height / 2)),
                                 New Point(CInt(Panel1.Width / 3) * 2, Panel1.Height),
                                 New Point(CInt(Panel1.Width / 3), Panel1.Height),
                                 New Point(0, CInt(Panel1.Height / 2)),
                                 New Point(CInt(Panel1.Width / 3), 0)}
        POLIGONO2.AddPolygon(PUNTOS2)
        Panel1.Region = New Region(POLIGONO2)
       
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        PictureBox1.Image = System.Drawing.Bitmap.FromFile(Application.StartupPath & "\IMAGEN.JPG")
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim POLIGONO3 As New GraphicsPath()
        Dim PUNTOS3 As Point() = {New Point(CInt(Me.Width / 3), 0),
                                 New Point(CInt(Me.Width / 3) * 2, 0),
                                 New Point(Me.Width, CInt(Me.Height / 2)),
                                 New Point(CInt(Me.Width / 3) * 2, Me.Height),
                                 New Point(CInt(Me.Width / 3), Me.Height),
                                 New Point(0, CInt(Me.Height / 2)),
                                 New Point(CInt(Me.Width / 3), 0)}
        POLIGONO3.AddPolygon(PUNTOS3)
        Me.Region = New Region(POLIGONO3)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    End Sub
    Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
        FLAG = True
    End Sub
    Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
        If FLAG = True Then
            Me.Location = New Point(Me.Location.X + e.X, Me.Location.Y + e.Y)
        End If
    End Sub
    Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
        FLAG = False
    End Sub
End Class

 04- Dibujo y Graficos, Cambio de Color de Pixeles,Visual Basic (VB.NET),Graphics. Daz Studio


 CODIGO:

FORM1:

 Imports System.Drawing.Imaging

Public Class Form1

    Dim bm As Bitmap

    ' Convert each pixel to grayscale.
    Private Sub btnGrayscale_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrayscale.Click

        Dim clr As Integer
        Dim xmax As Integer
        Dim ymax As Integer
        Dim x As Integer
        Dim y As Integer

        ' Get the bitmap and its dimensions.
        'Dim bm As Bitmap = picImage.Image
        xmax = bm.Width - 1
        ymax = bm.Height - 1

        ' Convert the pixels to grayscale.
        For y = 0 To ymax
            For x = 0 To xmax
                ' Convert this pixel.
                With bm.GetPixel(x, y)
                    clr = 0.3 * .R + 0.5 * .G + 0.2 * .B
                End With
                bm.SetPixel(x, y, _
                    Color.FromArgb(255, clr, clr, clr))
            Next x
        Next y

        ' Display the results.
        picHidden.Image = bm
    End Sub

    Private Sub BCARGARIMAGEN_Click(sender As Object, e As EventArgs) Handles BCARGARIMAGEN.Click
        OpenFileDialog1.ShowDialog()
        picImage.Image = System.Drawing.Bitmap.FromFile(OpenFileDialog1.FileName)

        bm = New Bitmap(picImage.Image)
        picHidden.Image = bm
    End Sub

    Private Sub BINVERTIR_Click(sender As Object, e As EventArgs) Handles BINVERTIR.Click
        RESTAURAR()
        Dim ROJO As Integer
        Dim VERDE As Integer
        Dim AZUL As Integer
        Dim xmax As Integer
        Dim ymax As Integer
        Dim x As Integer
        Dim y As Integer

        ' Get the bitmap and its dimensions.

        xmax = bm.Width - 1
        ymax = bm.Height - 1

        ' Convert the pixels to grayscale.
        For y = 0 To ymax
            For x = 0 To xmax
                ' Convert this pixel.

                With bm.GetPixel(x, y)

                    ROJO = 255 - .R
                    If ROJO < 0 Then
                        ROJO = 0
                    End If
                    VERDE = 255 - .G
                    If VERDE < 0 Then
                        VERDE = 0
                    End If
                    AZUL = 255 - .B
                    If AZUL < 0 Then
                        AZUL = 0
                    End If
                End With

                bm.SetPixel(x, y, _
                Color.FromArgb(255, ROJO, VERDE, AZUL))
            Next x
        Next y

        ' Display the results.
        picHidden.Image = bm

    End Sub


    Private Sub BROJOPORAZUL_Click(sender As Object, e As EventArgs) Handles BROJOPORAZUL.Click
        RESTAURAR()
        Dim ROJO As Integer
        Dim VERDE As Integer
        Dim AZUL As Integer
        Dim xmax As Integer
        Dim ymax As Integer
        Dim x As Integer
        Dim y As Integer

        ' Get the bitmap and its dimensions.

        xmax = bm.Width - 1
        ymax = bm.Height - 1

        ' Convert the pixels to grayscale.
        For y = 0 To ymax
            For x = 0 To xmax
                ' Convert this pixel.
                With bm.GetPixel(x, y)

                    ROJO = .R

                    VERDE = .G

                    AZUL = .B


                End With

                bm.SetPixel(x, y, _
                    Color.FromArgb(255, AZUL, VERDE, ROJO))
            Next x
        Next y

        ' Display the results.
        picHidden.Image = bm
    End Sub
    Public Sub RESTAURAR()
        bm = New Bitmap(picImage.Image)
        picHidden.Image = bm
    End Sub

    Private Sub BGUARDAR_Click(sender As Object, e As EventArgs) Handles BGUARDAR.Click
        If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
            If SaveFileDialog1.FileName.Contains(".bmp") Then
                bm.Save(SaveFileDialog1.FileName, ImageFormat.Bmp)
            End If
            If SaveFileDialog1.FileName.Contains(".jpg") Then
                bm.Save(SaveFileDialog1.FileName, ImageFormat.Jpeg)
            End If
            If SaveFileDialog1.FileName.Contains(".png") Then
                bm.Save(SaveFileDialog1.FileName, ImageFormat.Png)
            End If
        End If
    End Sub
   
End Class
 

15 comentarios:

  1. Respuestas
    1. Hola Jeffry:
      MuchasGracias.
      Me alegra saber que te gustan.
      Saludos.

      Eliminar
  2. Hola me encanta tu blog excelentes ejemplos, porfavor quisiera q me ayudes con un ejemplo de graficas de funciones de 2 variables

    ResponderEliminar
    Respuestas
    1. Hola: Gracias por el comentario. ¿Qué funciones con dos variables te interesan?. ¿Podrias poner un ejemplo?. Saludos.

      Eliminar
  3. Son geniales vuestros programas.

    Quiero fusionar 2 de vuestros programas en uno sólo, y me encuentro con el siguiente problema:

    Los programas vuestros que quiero fusionar son:

    1-Webcam a Video (Aforge) con Visual Basic (VB.NET)

    2-Copiar Parte de una Imagen y Guardarla con Visual Basic(VB.NET).Graphics

    La idea es poder dibujar el rectángulo del picturebox2, sobre el picturebox1 que captura vídeo en lugar de una imagen.

    El caso es que me funciona correctamente, pero el cuadro no se visualiza permanentemente sobre el vídeo. Cuando lo muevo, se desplaza correctamente, pero deja de visualizarse ya que es tapado por el vídeo.

    He probado a enviar el picturebox1 que contiene el vídeo al fondo, y traer al frente el picturebox2 con el rectángulo mediante un timer, pero no funciona.

    Por favor, si os es posible, os agradecería vuestra ayuda.

    Muchas gracias.

    ResponderEliminar
    Respuestas
    1. Hola:
      No acabo de entender muy bien que quieres hacer.¿Quieres guardar las imagenes de una zona del video?¿Dibujar un rectangulo sobre el Picturebox del video? ¿Superponer un Picturebox sobre otro?.¿...?.
      Cuantos mas detalles me des mas sencillo me resultara tratar de contestarte.
      En cualquier caso cada vez que se genera un fotograma del video se repinta el picturebox por lo que hay que estar "pintando" el rectangulo continuamente. Aqui tienes un ejemplo. Utiliza un Timer:
      http://visualbasictutoriales.blogspot.com.es/2015/06/deteccion-de-movimiento-y-su-direccion.html
      Saludos.

      Eliminar
  4. Disculpa hice la prueba en mi casa, copié el algoritmo de ¨Graficar funciones matemáticas¨, y me sale un error: "DATOS no está declarado"
    Podrías ayudarme en eso por favor

    ResponderEliminar
    Respuestas
    1. Hola:
      DATOS es el segundo formulario que solo contiene un Listview con los detalles numericos (X,Y) que aparece en el video. No tiene codigo. Quizas te resulte mas claro y comodo si descargas el proyecto aqui:
      http://visualbasictutoriales.blogspot.com.es/2013/12/15-graficar-funciones-matematicas-con.html
      Saludos.

      Eliminar
    2. Ok, gracias me ayudó bastante.

      Eliminar
    3. Hola.
      Perdona por insistir
      Creí que había solucionado el problema pero no
      Este es el algoritmo que descargue de tu blog (esta copiado solo la parte para graficar funciones polinómicas) y me sigue diciendo: DATOS no está declarado.
      Quizá sea necesario declarar DATOS como una variable? Lo siento no tengo mucho conocimiento en este programa

      Te agradecería mucho si me podrías ayudar

      Public Class Form1
      Dim VARX As New ArrayList
      Dim VARY As New ArrayList
      Dim ESCALA As Integer
      Dim CONTADOR As Integer = 0
      Dim DIBUJO As Graphics
      Dim BM As Bitmap
      Dim LAPIZ As New Pen(Color.Red, 5)
      Dim FUENTE As New Font("VERDANA", 8)

      Public Sub PREVIOS()
      DATOS.ListView1.Items.Clear()
      VARX.Clear()
      VARY.Clear()
      ESCALA = CSng(TextBoxZOOM.Text)
      For I = -5 To 5 Step CSng(TextBoxPASO.Text)
      VARX.Add((I * ESCALA))
      Next
      CONTADOR = 0
      End Sub
      Public Sub ALGEBRAICA()
      PREVIOS()
      Try
      Dim COEF1 As Single = CSng(TextBoxCOEF1.Text)
      Dim EXP1 As Single = CSng(TextBoxEXP1.Text)
      Dim COEF2 As Single = CSng(TextBoxCOEF2.Text)
      Dim EXP2 As Single = CSng(TextBoxEXP2.Text)
      Dim COEF3 As Single = CSng(TextBoxCOEF3.Text)
      Dim EXP3 As Single = CSng(TextBoxEXP3.Text)
      For I = -5 To 5 Step CSng(TextBoxPASO.Text)
      Try
      VARY.Add(Math.Pow((COEF1 * (Math.Pow(I, EXP1)) + (COEF2 * (Math.Pow(I, EXP2))) + COEF3), EXP3) * ESCALA)
      Catch ex As Exception
      End Try
      Dim listViewInformation(2) As String
      listViewInformation(0) = Math.Round(CSng(VARX(CONTADOR) / ESCALA), 2).ToString
      listViewInformation(1) = Math.Round(CSng(VARY(CONTADOR) / ESCALA), 2).ToString
      Dim item As ListViewItem = New ListViewItem(listViewInformation)
      DATOS.ListView1.Items.Add(item)
      CONTADOR += 1
      Next
      Catch ex As Exception
      MsgBox("REVISA TUS VALORES INICIALES")
      End Try
      End Sub
      Public Sub PINTA()
      BM = New Bitmap(PictureBox1.Width, PictureBox1.Height)
      DIBUJO = Graphics.FromImage(BM)
      DIBUJO.Clear(Color.White)
      DIBUJO.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
      DIBUJO.DrawLine(Pens.LightGray, CSng(PictureBox1.Width / 2), 0, CSng(PictureBox1.Width / 2), PictureBox1.Height)
      DIBUJO.DrawLine(Pens.LightGray, 0, CSng(PictureBox1.Height / 2), PictureBox1.Width, CSng(PictureBox1.Height / 2))
      DIBUJO.TranslateTransform(CSng(PictureBox1.Width / 2), CSng(PictureBox1.Height / 2))
      End Sub
      Public Sub PINTASINVALORES()

      PINTA()
      For I = 0 To VARX.Count - 2
      Try
      DIBUJO.DrawLine(LAPIZ, CSng(VARX(I)), CSng(VARY(I)) * -1, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)

      Catch ex As Exception
      End Try
      Next
      PictureBox1.Image = BM
      End Sub
      Public Sub PINTACONVALORES()

      PINTA()
      For I = 0 To VARX.Count - 2
      Try
      DIBUJO.DrawLine(LAPIZ, CSng(VARX(I)), CSng(VARY(I)) * -1, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)
      DIBUJO.DrawString("{" & Math.Round((VARX(I + 1) / ESCALA), 2) & " : " & Math.Round((VARY(I + 1) / ESCALA), 2) & "}",
      FUENTE, Brushes.Blue, CSng(VARX(I + 1)), CSng(VARY(I + 1)) * -1)
      Catch ex As Exception
      End Try
      Next
      PictureBox1.Image = BM
      End Sub

      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      PINTASINVALORES()
      ALGEBRAICA()
      DATOS.Show()

      Eliminar
  5. Hola: Tal como te dije en mi respuesta anterior DATOS NO es una variable. Es un formulario en el que se muestra el detalle de los valores X,Y.
    Es mejor que te descargues la aplicacion completa desde aqui:
    http://visualbasictutoriales.blogspot.com.es/2013/12/15-graficar-funciones-matematicas-con.html
    Asi podras probarla y ver los detalles.

    Saludos.

    ResponderEliminar
  6. Si tenés razón, es un Listview, ahora si definitivamente me di cuenta :p

    Te agradezco mucho tu atención

    ResponderEliminar
  7. COMO SE CAPTURARIA LA IMAGEN DE UNA FIRMA HECHA EN UNA TABLET,Y QUE REGISTRE EN UN POR EJEMPLO PICTUREBOX LA IMAGEN DE LA FIRMA CON LA PRESION DE ESCRITURA INCLUIDA

    ResponderEliminar
  8. que tal para poder girar una imagen pero en su propio eje se pude ??

    ResponderEliminar
  9. como puedo cambiar una grafica con otro teniendo en mismo codigo

    ResponderEliminar