Figures
© 2004 Microsoft Corporation. All rights reserved.
Figure 2 Get Info for BMP
Sub ShowBmpInfo(ByVal file As String)
        Dim fs As FileStream = New FileStream(file, FileMode.Open)
        Dim reader As BinaryReader = New BinaryReader(fs)

        ' skip the file header (14 bytes)
        reader.ReadBytes(14)

        ' skip the structure's size
        reader.ReadUInt32()

        ' read width and height
        Dim width As Int32 = reader.ReadInt32()
        Dim height As Int32 = reader.ReadInt32()

        ' skip 
        Dim planes As Int16 = reader.ReadInt16()

        ' read color depth (bit per pixel)
        Dim bitsPerPixel As Int16 = reader.ReadInt16()

        reader.Close()
        fs.Close()

        ' show info
        MsgBox(width & " x " & height & " x " & bitsPerPixel * planes)
End Sub
Page view tracker