Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/12/2009, 09:51
Avatar de neo101
neo101
 
Fecha de Ingreso: julio-2007
Mensajes: 73
Antigüedad: 16 años, 9 meses
Puntos: 1
Respuesta: Convertir Arreglo de bytes a imagen para PictureBox

Gracias por tu respuesta... pero que crees? No jala... Me dice que al imagen no es válida...

Para esto seré franco contigo, pues desgraciadamente estoy suponiendo que es una imagen (lo que realmente obtengo es una huella digital) y lo que quiero es representar la misma, pero me queda claro que no podré con un objeto Image pues, ya había probado con otros códigos y tampoco, me gustó el intento que propones para bajar el arreglo al archivo, pero creo que el formato del "arreglo de bytes" no es precisamente una imagen... te dejo un código que encontré por ahi, este simplemente no tiene efecto alguno...

Código vb:
Ver original
  1. ' Crea una imagen en memoria a partir de un arreglo de bytes...
  2. Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As Long, ppstm As Any) As Long
  3. Private Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes As Long) As Long
  4. Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
  5. Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
  6. Private Declare Function OleLoadPicture Lib "olepro32" (pStream As Any, ByVal lSize As Long, ByVal fRunmode As Long, riid As Any, ppvObj As Any) As Long
  7. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
  8.  
  9.  
  10. Public Function ArrayToPicture(inArray() As Byte, Offset As Long, Size As Long) As IPicture
  11.    
  12.     ' function creates a stdPicture from the passed array
  13.    ' Offset is first item in array: 0 for 0 bound arrays
  14.    ' Size is how many bytes comprise the image
  15.    Dim o_hMem  As Long
  16.     Dim o_lpMem  As Long
  17.     Dim aGUID(0 To 3) As Long
  18.     Dim IIStream As IUnknown
  19.    
  20.     aGUID(0) = &H7BF80980    ' GUID for stdPicture
  21.    aGUID(1) = &H101ABF32
  22.     aGUID(2) = &HAA00BB8B
  23.     aGUID(3) = &HAB0C3000
  24.    
  25.     o_hMem = GlobalAlloc(&H2&, Size)
  26.     If Not o_hMem = 0& Then
  27.         o_lpMem = GlobalLock(o_hMem)
  28.         If Not o_lpMem = 0& Then
  29.             CopyMemory ByVal o_lpMem, inArray(Offset), Size
  30.             Call GlobalUnlock(o_hMem)
  31.             If CreateStreamOnHGlobal(o_hMem, 1&, IIStream) = 0& Then
  32.                   Call OleLoadPicture(ByVal ObjPtr(IIStream), 0&, 0&, aGUID(0), ArrayToPicture)
  33.             End If
  34.         End If
  35.     End If
  36. End Function

Quiere decir que, necesito saber que es el arreglo de bytes?

Muchas Gracias por tu respuesta...
__________________
Everything that has a beginning, has an end...