Visual Basic - VIDEOCLUB-CLASE PARA IMÁGENES

Life is soft - evento anual de software empresarial
 
Vista:

VIDEOCLUB-CLASE PARA IMÁGENES

Publicado por OLIVIAS (1 intervención) el 30/05/2010 19:17:44
Public Class Clase1
Private laTabla As DataTable
Private laFila As Integer

Public Shared Function Image2Bytes(ByVal img As Image) As Byte()
Dim sTemp As String = Path.GetTempFileName()
Dim fs As New FileStream(sTemp, FileMode.OpenOrCreate, FileAccess.ReadWrite)
img.Save(fs, System.Drawing.Imaging.ImageFormat.Png)
' Cerrarlo y volverlo a abrir o posicionarlo en el primer byte
'fs.Close()
'fs = New FileStream(sTemp, FileMode.Open, FileAccess.Read)
fs.Position = 0
Dim imgLength As Integer = CInt(fs.Length)
Dim bytes(0 To imgLength - 1) As Byte
fs.Read(bytes, 0, imgLength)
fs.Close()
Return bytes
End Function

Public Shared Function Bytes2Image(ByVal bytes() As Byte) As Image
If bytes Is Nothing Then Return Nothing
Dim ms As New MemoryStream(bytes)
Dim bm As Bitmap = Nothing
Try
bm = New Bitmap(ms)
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
End Try
Return bm
End Function
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE: ME FALTABAN LAS 1ª LÍNEAS

Publicado por OLIVIAS (1 intervención) el 30/05/2010 19:29:00
Option Strict On
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.IO
Imports System.Drawing

Public Class Clase1
...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar