none
necesito ayuda con esto ! RRS feed

  • Pregunta

  • estoy tratando de hacer un paint para una tardea y no se como seleccionar una imagen, editarla y guardarla.

    Imports System.Drawing

    Public Class Form1

        Dim g As System.Drawing.Graphics

        Public Frelleno
        Public X1, Y1, X2, Y2, C, Ffigura As Integer

        Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
            g = Panel1.CreateGraphics()
        End Sub

        Public LapizColor As System.Drawing.Color

        Public Lapiz As System.Drawing.Pen
        Public Pincel As System.Drawing.Brushes

        Private Sub cb_color_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cb_color.SelectedIndexChanged
            Select Case Me.cb_color.Text
                Case "Negro"
                    LapizColor = Color.Black
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Amarillo"
                    LapizColor = Color.Yellow
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Rojo"
                    LapizColor = Color.Red
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Azul"
                    LapizColor = Color.Blue
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Marron"
                    LapizColor = Color.Brown
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Violeta"
                    LapizColor = Color.Violet
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Verde"
                    LapizColor = Color.Green
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case "Morado"
                    LapizColor = Color.Purple
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
                Case Else
                    LapizColor = Color.Black
                    Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
            End Select
        End Sub

        Private Sub bt_borrar_Click(sender As Object, e As EventArgs) Handles bt_borrar.Click
            Panel1.Refresh()
        End Sub

        Private Sub cb_tamaño_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cb_tamaño.SelectedIndexChanged
            Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
        End Sub

        Public Flag

        Private Sub bt_goma_Click(sender As Object, e As EventArgs) Handles bt_goma.Click
            LapizColor = Color.White
            Lapiz = New Pen(LapizColor, CInt(cb_tamaño.Text))
        End Sub

        Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles cbrelleno.CheckedChanged
            If cbrelleno.Checked = True Then
                Frelleno = 1
            Else Frelleno = 0
            End If
        End Sub

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

            LapizColor = Color.Black
            Lapiz = New Pen(LapizColor, 1)
            cb_color.Text = "Negro"
            cb_tamaño.Text = 1
            Flag = 0

        End Sub

        Private Sub Panel1_MouseDown(sender As Object, e As MouseEventArgs) Handles Panel1.MouseDown

            If rblapiz.Checked = True Then
                Flag = 1
            Else
                X1 = e.X
                Y1 = e.Y
            End If
        End Sub

        Private Sub Panel1_MouseMove(sender As Object, e As MouseEventArgs) Handles Panel1.MouseMove


            If rblapiz.Checked = True And Flag = 0 Then
                X1 = e.X
                Y1 = e.Y
                X2 = X1
                Y2 = Y1

            ElseIf rblapiz.Checked = True And Flag = 1 Then
                X1 = e.X
                Y1 = e.Y
                Dim Punto = Panel1.CreateGraphics
                Punto.DrawLine(Lapiz, X1, Y1, X2, Y2)
                X2 = X1
                Y2 = Y1
            End If
        End Sub
        Private Sub Panel1_MouseUp(sender As Object, e As MouseEventArgs) Handles Panel1.MouseUp
            If rblapiz.Checked = False Then
                X2 = e.X
                Y2 = e.Y
            End If
            If rbrectangulo.Checked = True And cbrelleno.Checked = False Then
                g.DrawRectangle(Lapiz, New Rectangle(New Point(X1, Y1), New Size(X2 - X1, Y2 - Y1)))
            ElseIf rbrectangulo.Checked = True Then
                Using Pincel = New SolidBrush(LapizColor)
                    g.FillRectangle(Pincel, X1, Y1, X2 - X1, Y2 - Y1)
                End Using
            ElseIf rbcuadrado.Checked = True And cbrelleno.Checked = False Then
                g.DrawRectangle(Lapiz, New Rectangle(New Point(X1, Y1), New Size(X2 - X1, X2 - X1)))
            ElseIf rbcuadrado.Checked = True Then
                Using Pincel = New SolidBrush(LapizColor)
                    g.FillRectangle(Pincel, X1, Y1, X2 - X1, X2 - X1)
                End Using
            ElseIf rbcirculo.Checked = True And cbrelleno.Checked = False Then
                g.DrawEllipse(Lapiz, X1, Y1, X2 - X1, X2 - X1)
            ElseIf rbcirculo.Checked = True Then
                Using Pincel = New SolidBrush(LapizColor)
                    g.FillEllipse(Pincel, X1, Y1, X2 - X1, X2 - X1)
                End Using
            ElseIf rbelipse.Checked = True And cbrelleno.Checked = False Then
                g.DrawEllipse(Lapiz, X1, Y1, X2 - X1, Y2 - Y1)
            ElseIf rbelipse.Checked = True Then
                Using Pincel = New SolidBrush(LapizColor)
                    g.FillEllipse(Pincel, X1, Y1, X2 - X1, Y2 - Y1)
                End Using
            Else
                Flag = 0
            End If
        End Sub
    End Class

    • Cambiado Enrique M. Montejo lunes, 9 de mayo de 2016 7:42 Pregunta relacionada con aplicación de Windows Forms.
    domingo, 8 de mayo de 2016 0:37