Half of day 38 complete.
This commit is contained in:
+29
-11
@@ -110,7 +110,11 @@ static void DrawBitmap(game_offscreen_buffer *Buffer, loaded_bitmap *Bitmap, F32
|
||||
U32 *Dest = (U32 *)DestRow;
|
||||
U32 *Source = SourceRow;
|
||||
for(S32 X = MinX; X < MaxX; X++) {
|
||||
*Dest++ = *Source++;
|
||||
if((*Source >> 24) > 128)
|
||||
*Dest = *Source;
|
||||
|
||||
Dest++;
|
||||
Source++;
|
||||
}
|
||||
DestRow += Buffer->Pitch;
|
||||
SourceRow -= Bitmap->Width;
|
||||
@@ -147,29 +151,43 @@ static loaded_bitmap DEBUGLoadBMP(thread_context *Thread, debug_read_file_result
|
||||
loaded_bitmap Result;
|
||||
memset(&Result, 0, sizeof(Result));
|
||||
|
||||
// NOTE: Byte order in memory is AA BB GG RR, bottom up.
|
||||
// Littel-endian: 0xRRGGBBAA
|
||||
|
||||
debug_read_file_result ReadResult = DEBUGPlatformReadEntireFile(Thread, FileName);
|
||||
if(ReadResult.ContentsSize > 0) {
|
||||
bitmap_header *Header = (bitmap_header *)ReadResult.Contents;
|
||||
|
||||
U32 *Pixels = (U32 *)((U8 *)ReadResult.Contents + Header->BitmapOffset);
|
||||
Result.Pixels = Pixels;
|
||||
Result.Width = Header->Width;
|
||||
Result.Width = Header->Width;
|
||||
Result.Height = Header->Height;
|
||||
|
||||
// TODO: Is this too outdated? As of 2026, this loads fine on little-endian.
|
||||
// Maybe my BMP uses a newer format.
|
||||
/*
|
||||
// NOTE: The byte order in memory is determined by the Header.
|
||||
|
||||
U32 RedMask = Header->RedMask;
|
||||
U32 GreenMask = Header->GreenMask;
|
||||
U32 BlueMask = Header->BlueMask;
|
||||
U32 AlphaMask = ~(RedMask | GreenMask | BlueMask);
|
||||
|
||||
bit_scan_result RedShift = FindLeastSignificantSetBit(RedMask);
|
||||
bit_scan_result GreenShift = FindLeastSignificantSetBit(GreenMask);
|
||||
bit_scan_result BlueShift = FindLeastSignificantSetBit(BlueMask);
|
||||
bit_scan_result AlphaShift = FindLeastSignificantSetBit(AlphaMask);
|
||||
|
||||
ASSERT(RedShift.Found);
|
||||
ASSERT(GreenShift.Found);
|
||||
ASSERT(BlueShift.Found);
|
||||
ASSERT(AlphaShift.Found);
|
||||
|
||||
U32 *SourceDest = Pixels;
|
||||
for(S32 Y = 0; Y < Header->Height; Y++) {
|
||||
for(S32 X = 0; X < Header->Width; X++) {
|
||||
*SourceDest = (*SourceDest >> 8) | (*SourceDest << 24);
|
||||
SourceDest++;
|
||||
U32 C = *SourceDest;
|
||||
|
||||
*SourceDest = ((((C >> AlphaShift.Index) & 0xFF) << 24) |
|
||||
(((C >> RedShift.Index ) & 0xFF) << 16) |
|
||||
(((C >> GreenShift.Index) & 0xFF) << 8) |
|
||||
(((C >> BlueShift.Index ) & 0xFF) << 8));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
||||
Reference in New Issue
Block a user