Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Compression BitMap

Estas en el tema de Compression BitMap en el foro de Visual Basic clásico en Foros del Web. Hola que tal muchachos, bueno miren yo ando con un problema que no lo puedo solucionar, yo necesito descomprimir una imagen de bits, tengo el ...
  #1 (permalink)  
Antiguo 27/10/2012, 13:17
 
Fecha de Ingreso: octubre-2012
Mensajes: 29
Antigüedad: 11 años, 6 meses
Puntos: 0
Compression BitMap

Hola que tal muchachos, bueno miren yo ando con un problema que no lo puedo solucionar, yo necesito descomprimir una imagen de bits, tengo el modulo de descompression, yo quiero descomprimirlo usando la función ExtractData, pero la verdad que no entiendo que parámetros hay que usar, porque no logro descomprimirlo!!

Sería una cosa así: Call ExtractData(Param1, Param2, Param3)

Miren el módulo:

Código vb:
Ver original
  1. Option Explicit
  2. Public NumBMP As Long
  3.  
  4. 'Bitmap file format structures
  5. Type BITMAPFILEHEADER
  6.     bfType As Integer
  7.     bfSize As Long
  8.     bfReserved1 As Integer
  9.     bfReserved2 As Integer
  10.     bfOffBits As Long
  11. End Type
  12.  
  13. Type BITMAPINFOHEADER
  14.     biSize As Long
  15.     biWidth As Long
  16.     biHeight As Long
  17.     biPlanes As Integer
  18.     biBitCount As Integer
  19.     biCompression As Long
  20.     biSizeImage As Long
  21.     biXPelsPerMeter As Long
  22.     biYPelsPerMeter As Long
  23.     biClrUsed As Long
  24.     biClrImportant As Long
  25. End Type
  26.  
  27. Type RGBQUAD
  28.     rgbBlue As Byte
  29.     rgbGreen As Byte
  30.     rgbRed As Byte
  31.     rgbReserved As Byte
  32. End Type
  33.  
  34. Type BITMAPINFO
  35.     bmiHeader As BITMAPINFOHEADER
  36.     bmiColors(0 To 255) As RGBQUAD
  37. End Type
  38.  
  39. Public Type tGP
  40.     File As Integer
  41.     OffSet As Long
  42.     Height As Long
  43.     Width As Long
  44.     FileSizeBMP As Long
  45. End Type
  46.  
  47. Public GPdataBMP() As tGP
  48.  
  49. Global gudtBMPFileHeader As BITMAPFILEHEADER   'Holds the file header
  50. Global gudtBMPInfo As BITMAPINFO               'Holds the bitmap info
  51. Global gudtBMPData() As Byte                   'Holds the pixel data
  52.  
  53. Sub ExtractData(strFileName As String, lngOffset As Long, FileSizeBMP As Long)
  54.    Dim intBMPFile As Integer
  55.    intBMPFile = FreeFile
  56.    If FileSizeBMP = 0 Then Exit Sub
  57.    Open strFileName For Binary Access Read Lock Write As intBMPFile
  58.         ReDim gudtBMPData(FileSizeBMP - 1)
  59.         'Get the data
  60.        Get intBMPFile, lngOffset, gudtBMPData()
  61.     Close #intBMPFile
  62. Exit Sub
  63. On Error Resume Next
  64. 'Dim intBMPFile As Integer
  65. Dim I As Integer
  66.  
  67.     'Init variables
  68.    Erase gudtBMPInfo.bmiColors
  69.  
  70.     'Open the bitmap
  71.    intBMPFile = FreeFile()
  72.     Open strFileName For Binary Access Read Lock Write As intBMPFile
  73.         'Fill the File Header structure
  74.  
  75.         Get intBMPFile, lngOffset, gudtBMPFileHeader
  76.         'Fill the Info structure
  77.        Get intBMPFile, , gudtBMPInfo.bmiHeader
  78.         If gudtBMPInfo.bmiHeader.biClrUsed <> 0 Then
  79.             For I = 0 To gudtBMPInfo.bmiHeader.biClrUsed - 1
  80.                 Get intBMPFile, , gudtBMPInfo.bmiColors(I).rgbBlue
  81.                 Get intBMPFile, , gudtBMPInfo.bmiColors(I).rgbGreen
  82.                 Get intBMPFile, , gudtBMPInfo.bmiColors(I).rgbRed
  83.                 Get intBMPFile, , gudtBMPInfo.bmiColors(I).rgbReserved
  84.             Next I
  85.         ElseIf gudtBMPInfo.bmiHeader.biBitCount = 8 Or gudtBMPInfo.bmiHeader.biBitCount = 4 Then
  86.             Get intBMPFile, , gudtBMPInfo.bmiColors
  87.         End If
  88.         'Size the BMPData array
  89.        If gudtBMPInfo.bmiHeader.biBitCount = 8 Then
  90.             ReDim gudtBMPData(FileSize(gudtBMPInfo.bmiHeader.biWidth, gudtBMPInfo.bmiHeader.biHeight))
  91.         Else
  92.             ReDim gudtBMPData(gudtBMPInfo.bmiHeader.biSizeImage - 1)
  93.         End If
  94.         ReDim gudtBMPData(FileSizeBMP)
  95.         'Fill the BMPData array
  96.        Get intBMPFile, , gudtBMPData
  97.         'Ensure info is correct
  98.        If gudtBMPInfo.bmiHeader.biBitCount = 8 Then
  99.             gudtBMPFileHeader.bfOffBits = 1078
  100.             gudtBMPInfo.bmiHeader.biSizeImage = FileSizeBMP 'FileSize(gudtBMPInfo.bmiHeader.biWidth, gudtBMPInfo.bmiHeader.biHeight)
  101.            gudtBMPInfo.bmiHeader.biClrUsed = 0
  102.             gudtBMPInfo.bmiHeader.biClrImportant = 0
  103.             gudtBMPInfo.bmiHeader.biXPelsPerMeter = 0
  104.             gudtBMPInfo.bmiHeader.biYPelsPerMeter = 0
  105.         End If
  106.     Close intBMPFile
  107.    
  108. End Sub
  109.  
  110. Private Function FileSize(lngWidth As Long, lngHeight As Long) As Long
  111.     'Return the size of the image portion of the bitmap
  112.    If lngWidth Mod 4 > 0 Then
  113.         FileSize = ((lngWidth \ 4) + 1) * 4 * lngHeight - 1
  114.     Else
  115.         FileSize = lngWidth * lngHeight - 1
  116.     End If
  117. End Function

Bueno, gracias de ante mano!
  #2 (permalink)  
Antiguo 28/10/2012, 08:44
 
Fecha de Ingreso: octubre-2012
Mensajes: 13
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: Compression BitMap

mm, pues la verdad no podria ayudarte con ese codigo, te puedo aconsejar que lo intentes asi
call shell("directorio/winrar.exe " & "Directorio/imagencomprimida.rar")
tal vez te funcione

Etiquetas: bitmap, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:39.