Hello, I'm trying to load BMP file header to type using FileStream readData,
but it doesn't work. I have to read every single variable separately. If I try
to load it with readData, there is some weird result, missing data, etc.
type
BitmapFileHeader* = object
signature*: array[2, char]
size*: uint32
reservedOne*: uint16
reservedTwo*: uint16
offset*: uint32
proc loadBitmapFileHeader*(bitmap: Bitmap, file: FileStream):
BitmapFileHeader =
file.setPosition(0)
result.signature[0] = file.readChar()
result.signature[1] = file.readChar()
result.size = file.readUint32()
result.reservedOne = file.readUint16()
result.reservedTwo = file.readUint16()
result.offset = file.readUint32()
#TODO: Check if all bytes have been read
return result
Is there any way to load it like this?
proc loadBitmapFileHeader*(bitmap: Bitmap, file: FileStream):
BitmapFileHeader =
file.setPosition(0)
let readBytes = file.readData(bitmap.fileHeader.addr, 14)
return result