Option Explicit
Public Type BITMAP
bmHead As String * 18
bmWidth As Long
bmHeight As Long
End Type
Sub GetBitmapPixel()
Dim bmp As BITMAP
Dim intFile As Integer
Dim strTmp As String * 54
Dim lngBytes As Long
Dim bytPixel() As Byte
Const BMPFILE = "D:\3x3.bmp"
'Höhe und Breite des Bitmaps aus Header auslesen
intFile = FreeFile
Open BMPFILE For Binary Access Read As #intFile
Get #intFile, , bmp
Close #intFile
'Größe bestimmen
lngBytes = bmp.bmHeight * (bmp.bmWidth * 3 + bmp.bmWidth Mod 4)
ReDim bytPixel(0 To lngBytes - 1)
intFile = FreeFile
Open BMPFILE For Binary Access Read As #intFile
Get #intFile, , strTmp
Get #intFile, , bytPixel
Close #intFile
'Pixel sind jetzt im Array bytPixel.
End Sub
Gruß
Christoph
PS: Der Code läuft bei 24bit Bitmaps. Ob sich Header und Aufbau bei anderer Farbtiefe unterscheiden, musst du noch recherchieren.
Sub BMPSize(D As String, Wdth As Long, Hght As Long)
Dim Nr As Integer
Dim Dmmy As String * 18
Nr = FreeFile
Open D$ For Binary As #Nr
Get #Nr, , Dmmy
Get #Nr, , Wdth
Get #Nr, , Hght
Close #Nr
End Sub
Wie gesagt, ich sehe, dass es funktioniert, aber ich kapier nicht wie. Aber Hauptsache ...
Und ganz fettes DANKE nochmal.