10 #include <SDL_image.h>
29 const json uiDataJSON = json::parse(jsonFileContent,
nullptr,
false);
32 if (uiDataJSON.is_discarded())
35 for (
const auto &tileID : uiDataJSON.items())
37 for (
auto it = uiDataJSON[tileID.key()].begin(); it != uiDataJSON[tileID.key()].end(); ++it)
84 SDL_Surface *surface = IMG_Load(fName.c_str());
99 throw UIError(
TRACE_INFO "Texture could not be created! SDL Error: " +
string{SDL_GetError()});
106 SDL_FreeSurface(it.second);
112 SDL_DestroyTexture(it.second);
118 for (
const auto &ita : it.second)
120 SDL_DestroyTexture(ita.second);
128 SDL_Color Color{0, 0, 0, SDL_ALPHA_TRANSPARENT};
132 const int bpp = surface->format->BytesPerPixel;
133 Uint8 *p = &
static_cast<Uint8 *
>(surface->pixels)[y * surface->pitch + x * bpp];
134 const Uint32 pixel = *
reinterpret_cast<Uint32 *
>(p);
136 SDL_GetRGBA(pixel, surface->format, &Color.r, &Color.g, &Color.b, &Color.a);