Some improvements to rendering of program icon.
This commit is contained in:
+7
-25
@@ -635,7 +635,7 @@ 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++) {
|
||||
F32 A = (F32)((*Source >> 24) & 0xFF) / 255.0f;
|
||||
F32 SA = (F32)((*Source >> 24) & 0xFF);
|
||||
F32 SR = (F32)((*Source >> 16) & 0xFF);
|
||||
F32 SG = (F32)((*Source >> 8) & 0xFF);
|
||||
F32 SB = (F32)((*Source >> 0) & 0xFF);
|
||||
@@ -644,12 +644,14 @@ static void DrawBitmap(game_offscreen_buffer *Buffer, loaded_bitmap *Bitmap, F32
|
||||
F32 DG = (F32)((*Dest >> 8) & 0xFF);
|
||||
F32 DB = (F32)((*Dest >> 0) & 0xFF);
|
||||
|
||||
F32 A = SA / 255.0f;
|
||||
|
||||
// TODO: This should be replaced by premultiplied alpha.
|
||||
F32 R = (1.0f-A)*DR + A*SR;
|
||||
F32 G = (1.0f-A)*DG + A*SG;
|
||||
F32 B = (1.0f-A)*DB + A*SB;
|
||||
|
||||
*Dest = (((U32)RoundF32toS32(R) << 16) | ((U32)RoundF32toS32(G) << 8) | ((U32)RoundF32toS32(B) << 0));
|
||||
*Dest = (((U32)RoundF32toS32(SA) << 24) | ((U32)RoundF32toS32(R) << 16) | ((U32)RoundF32toS32(G) << 8) | ((U32)RoundF32toS32(B) << 0));
|
||||
|
||||
Dest++;
|
||||
Source++;
|
||||
@@ -729,21 +731,6 @@ static loaded_bitmap DEBUGLoadBMPP(thread_context *Thread, debug_read_file_resul
|
||||
SourceDest++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
U32 *Beginning = Pixels;
|
||||
U32 *Ending = Pixels + (Header->Width * Header->Height);
|
||||
for(S32 Y = 0; Y < Header->Height; Y++) {
|
||||
for(S32 X = 0; X < Header->Width; X++) {
|
||||
U32 Temp = *Beginning;
|
||||
*Beginning = *Ending;
|
||||
*Ending = Temp;
|
||||
|
||||
Beginning++;
|
||||
Ending--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return Result;
|
||||
@@ -751,13 +738,7 @@ static loaded_bitmap DEBUGLoadBMPP(thread_context *Thread, debug_read_file_resul
|
||||
|
||||
void SDLSetProgramIcon(SDL_Window *Window, game_offscreen_buffer *ProgramIcon)
|
||||
{
|
||||
U32 Rmask, Gmask, Bmask, Amask;
|
||||
Rmask = 0x00ff0000;
|
||||
Gmask = 0x0000ff00;
|
||||
Bmask = 0x000000ff;
|
||||
Amask = 0xff000000;
|
||||
|
||||
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom((void *)ProgramIcon->Memory, ProgramIcon->Width, ProgramIcon->Height, ProgramIcon->BytesPerPixel * 8, ProgramIcon->BytesPerPixel * ProgramIcon->Width, Rmask, Gmask, Bmask, Amask);
|
||||
SDL_Surface *icon = SDL_CreateRGBSurfaceWithFormatFrom((void *)ProgramIcon->Memory, ProgramIcon->Width, ProgramIcon->Height, ProgramIcon->BytesPerPixel * 8, ProgramIcon->BytesPerPixel * ProgramIcon->Width, SDL_PIXELFORMAT_ARGB8888);
|
||||
if(icon) {
|
||||
SDL_SetWindowIcon(Window, icon);
|
||||
SDL_FreeSurface(icon);
|
||||
@@ -814,7 +795,8 @@ S32 main(S32 argc, char *argv[])
|
||||
ProgramIconBuffer.Width = ProgramIcon.Width;
|
||||
ProgramIconBuffer.Height = ProgramIcon.Height;
|
||||
ProgramIconBuffer.BytesPerPixel = 4;
|
||||
ProgramIconBuffer.Pitch = 4 * ProgramIcon.Width;
|
||||
ProgramIconBuffer.Pitch = ProgramIconBuffer.BytesPerPixel * ProgramIcon.Width;
|
||||
memset(ProgramIconBuffer.Memory, 0, (ProgramIcon.Width * ProgramIcon.Height) * ProgramIconBuffer.BytesPerPixel);
|
||||
|
||||
DrawBitmap(&ProgramIconBuffer, &ProgramIcon, 0, 0, 0, 0);
|
||||
SDLSetProgramIcon(Window, &ProgramIconBuffer);
|
||||
|
||||
Reference in New Issue
Block a user