none
guardar imagen del picture box a la base de datos sin guardar en el ordenador RRS feed

  • Pregunta

  • tengo el siguiente codigo para hacer el dibujo en el picturebox

     

    Imports System.Drawing.Image
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Private pulsado As Boolean = False
        Private xant, yant As Integer
        Private superficie As Graphics
        Private superficie2 As Graphics
        Private b As Bitmap
        Private boton As Integer
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim ancho, alto As Integer
            superficie = PictureBox1.CreateGraphics()
            ancho = PictureBox1.ClientSize.Width
            alto = PictureBox1.ClientSize.Height
            b = New Bitmap(ancho, alto)
            superficie2 = Graphics.FromImage(b)
            Dim conexion As New Cconexion
            Dim tabla As New DataTable
    
            If conexion.consultar_todos Then
                tabla = conexion.tabla
                DataGridView1.DataSource = tabla
            Else
                MessageBox.Show("Error al consultar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
    
        End Sub
    
        Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
    
        End Sub
    
        Private Sub PictureBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
            pulsado = Not (pulsado)
            boton = e.Button
            If (pulsado) Then
                xant = e.X
                yant = e.Y
            End If
        End Sub
    
        Private Sub PictureBox1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
            Dim lapiz As Pen
            If (boton = MouseButtons.Left) Then
                lapiz = Pens.Black
            Else
            End If
            Dim x, y As Integer
            x = e.X
            y = e.Y
            Dim ctrl As Boolean
            ctrl = (Control.ModifierKeys = Keys.Control)
            If ((xant <> x) Or (yant <> y)) Then
                If ((pulsado) And (Not ctrl)) Then
                    superficie.DrawLine(lapiz, xant, yant, x, y)
                    superficie2.DrawLine(lapiz, xant, yant, x, y)
                End If
                xant = x
                yant = y
            End If
    
        End Sub
    
        Private Sub PictureBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
            pulsado = Not (pulsado)
            boton = e.Button
            If Not (pulsado) Then
                xant = e.X
                yant = e.Y
            End If
    
        End Sub
    
        Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
            superficie.DrawImage(b, 0, 0)
        End Sub

    la intencion es guardar (b) a la base de datos de sql con extension image sin tener que guardar el archivo con un savedialog. He leido de pasarlo a un array pero no se por donde empezar

    para luego crear un reporte y usar (b) en otro picturebox para mostrarlo

    gracias por vuestro tiempo


    • Editado Sir16 miércoles, 9 de noviembre de 2011 1:04
    miércoles, 9 de noviembre de 2011 1:02

Respuestas

Todas las respuestas