DecodeABIC2 Example for Visual Basic

Private Type RGBQUAD
   rgbBlue As Byte
   rgbGreen As Byte
   rgbRed As Byte
   rgbReserved As Byte
End Type

Private Type BITMAPFILEHEADER
   bfType As Integer
   bfSize As Long
   bfReserved1 As Integer
   bfReserved2 As Integer
   bfOffBits As Long
End Type


Private Type BITMAPINFOHEADER '40 bytes
   biSize As Long
   biWidth As Long
   biHeight As Long
   biPlanes As Integer
   biBitCount As Integer
   biCompression As Long
   biSizeImage As Long
   biXPelsPerMeter As Long
   biYPelsPerMeter As Long
   biClrUsed As Long
   biClrImportant As Long
End Type


Private Type BITMAPINFO
   bmiHeader As BITMAPINFOHEADER
   bmiColors(16) As RGBQUAD
End Type

Private Sub DecodeAbic_Click()
   Dim RasterIO As New LEADRasterIO
   Dim InputData As Variant
   Dim OutputData As Variant
   Dim FileSize As Long
   Dim FileName As String
   Dim Data() As Byte
   Dim i As Long
   Dim BmpInfo As BITMAPINFO
   Dim BmpFileHeader As BITMAPFILEHEADER
   Dim BmpData As Byte

   LEADRasterView1.Raster.UnlockSupport L_SUPPORT_ABIC_READ, L_KEY_ABIC_READ

   FileName = "c:\Image2Raw2.ica"
   FileSize = FileLen(FileName)
   ReDim Data(FileSize) As Byte

   Open FileName For Binary Access Read As #1
   Get #1, , Data
   Close #1

   InputData = Data

   RasterIO.DecodeABIC2 InputData, OutputData, 4, 472, 221, False

   BmpInfo.bmiHeader.biSize = Len(BmpInfo.bmiHeader)
   BmpInfo.bmiHeader.biWidth = 472
   BmpInfo.bmiHeader.biHeight = 221
   BmpInfo.bmiHeader.biBitCount = 4

   BmpFileHeader.bfType = Asc("B") + (Asc("M") * 2 ^ 8)
   BmpFileHeader.bfSize = Len(BmpInfo) + Len(BmpFileHeader) + UBound(OutputData) - LBound(OutputData)
   BmpFileHeader.bfReserved1 = 0
   BmpFileHeader.bfReserved2 = 0
   BmpFileHeader.bfOffBits = Len(BmpInfo) + Len(BmpFileHeader)

   For i = 0 To 15
      BmpInfo.bmiColors(i).rgbBlue = &H11 * i
      BmpInfo.bmiColors(i).rgbRed = &H11 * i
      BmpInfo.bmiColors(i).rgbGreen = &H11 * i
      BmpInfo.bmiColors(i).rgbReserved = 0
   Next i

   Open "c:\Abic2.bmp" For Binary Access Write As #1
   Put #1, , BmpFileHeader
   Put #1, , BmpInfo

   For i = 0 To UBound(OutputData) - LBound(OutputData)
      BmpData = CByte(OutputData(i))
      Put #1, , BmpData
   Next i
   Close #1
End Sub