Imports System
Imports System.IO
Public Class BmpHeightWidth
Public Shared Sub Main()
Dim myFile As BinaryReader
Dim b1, b2 As Byte
Dim width, height As Integer
myFile = New BinaryReader(File.Open("example.bmp", FileMode.Open))
b1 = myFile.ReadByte()
b2 = myFile.ReadByte()
If (b1 = &H42) AndAlso (b2 = &H4D) Then
Console.WriteLine("It seems to be a BMP file")
myFile.BaseStream.Seek(18, SeekOrigin.Begin)
width = myFile.ReadInt32()
height = myFile.ReadInt32()
Console.WriteLine("Width: {0} pixels", width)
Console.WriteLine("Height: {0} pixels", height)
Else
Console.WriteLine("It DOES NOT seem to be a BMP file")
End If
myFile.Close()
End Sub
End Class