sim: embedd background bmp and load from memory

Loading the file from disk introduces a slight dependency on the working
directory for the simulator. Prevent that by loading the bmp from
memory.

Use a python script to convert the backround bmp image to a C header
file. Include this header in `main.cpp` and load the bmp from memory.
This commit is contained in:
Reinhold Gschweicher
2023-05-08 18:30:13 +02:00
parent 1c479a2875
commit aa34f93161
4 changed files with 57 additions and 2 deletions

View File

@@ -69,6 +69,8 @@
#endif
#include <gif.h>
#include "img/sim_background.h" // provides variable SIM_BACKGROUND
/*********************
* DEFINES
*********************/
@@ -426,8 +428,10 @@ public:
init_NRF_WDT();
init_NRF_POWER();
// Attempt to load background PNG for the status display window
SDL_Surface* simDisplayBgRaw = SDL_LoadBMP("img/sim_background.bmp");
// Attempt to load background BMP from memory for the status display window
const size_t SIM_BACKGROUND_size = sizeof(SIM_BACKGROUND);
SDL_RWops *rw = SDL_RWFromMem((void*)SIM_BACKGROUND, SIM_BACKGROUND_size);
SDL_Surface* simDisplayBgRaw = SDL_LoadBMP_RW(rw, 1);
if (simDisplayBgRaw == NULL) {
printf("Failed to load sim background image: %s\n", SDL_GetError());
} else {