For some reason the function DEBUGLoadBMP() (day 37) doesn't work for me, when I launch the EXE I don't see any bitmap. Moreover VS debugger return weird values for the header struct:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | FileType 2624998722 unsigned __int64
FileSize 3538944 unsigned int
Reserved1 28147497673687040 unsigned __int64
Reserved2 281474983264256 unsigned __int64
BitmapOffset 32 unsigned int
Size 0 unsigned int
Width 185729024 int
Height 185729024 int
Planes 0 unsigned __int64
BitsPerPixel 18446742974197923840 unsigned __int64
Compression 4294967295 unsigned int
SizeOfBitmap 4294967295 unsigned int
HorzResolution -1 int
VertResolution -1 int
ColorsUsed 4294967295 unsigned int
ColorsImportant 4294967295 unsigned int
RedMask 4294967295 unsigned int
GreenMask 4294967295 unsigned int
BlueMask 4294967295 unsigned int
|
For example, HxW should be 100x100. And yes, I used #pragma pack(push, 1)/#pragma pack(pop) on
bitmap_header.
For completness I also include the DEBUGLoadBMP() code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | internal loaded_bitmap
DEBUGLoadBMP(thread_context *Thread, debug_platform_read_entire_file *ReadEntireFile, char *FileName)
{
loaded_bitmap Result = {};
// NOTE(casey): Byte order in memory is AA BB GG RR, bottom up.
// In little endian -> 0xRRGGBBAA
debug_read_file_result ReadResult = ReadEntireFile(Thread, FileName);
if(ReadResult.ContentsSize != 0)
{
bitmap_header *Header = (bitmap_header *)ReadResult.Contents;
uint32 *Pixels = (uint32 *)((uint8 *)ReadResult.Contents + Header->BitmapOffset);
Result.Pixels = Pixels;
Result.Width = Header->Width;
Result.Height = Header->Height;
uint32 *SourceDest = Pixels;
for (int32 Y = 0; Y < Header->Height; ++Y) {
for (int32 X = 0; X < Header->Width; ++X) {
/* 0xRRGGBBAA -> 0xAARRGGBB*/
*SourceDest = (*SourceDest >> 8) | (*SourceDest << 24);
++SourceDest;
}
}
}
return(Result);
}
|
Any clue?
Thanks in advance.