| 87 | } |
| 88 | |
| 89 | SDL_Surface* get(const char* imagePath) |
| 90 | { |
| 91 | ImageMap::iterator iImage = s_images.find(imagePath); |
| 92 | if (iImage != s_images.end()) |
| 93 | { |
| 94 | return iImage->second; |
| 95 | } |
| 96 | |
| 97 | SDL_Surface* sdlimg = IMG_Load(imagePath); |
| 98 | if (!sdlimg) |
| 99 | { |
| 100 | TFE_System::logWrite(LOG_ERROR, "Image", "Cannot load image from '%s', error: '%s'", imagePath, SDL_GetError()); |
| 101 | return nullptr; |
| 102 | } |
| 103 | |
| 104 | if (sdlimg->format->BitsPerPixel != 32) |
| 105 | { |
| 106 | sdlimg = convertToRGBA(sdlimg); |
| 107 | } |
| 108 | if (!sdlimg) |
| 109 | { |
| 110 | TFE_System::logWrite(LOG_ERROR, "Image", "Cannot convert image '%s' to 32-bits, error: '%s'", imagePath, SDL_GetError()); |
| 111 | return nullptr; |
| 112 | } |
| 113 | |
| 114 | s_images[imagePath] = sdlimg; |
| 115 | return sdlimg; |
| 116 | } |
| 117 | |
| 118 | void free(SDL_Surface* image) |
| 119 | { |
nothing calls this directly
no test coverage detected