* Loads the contents of an image file of a * known format into the surface. * @param filename Filename of the image. */
| 248 | * @param filename Filename of the image. |
| 249 | */ |
| 250 | void Surface::loadImage(const std::string &filename) |
| 251 | { |
| 252 | // Destroy current surface (will be replaced) |
| 253 | DeleteAligned(_alignedBuffer); |
| 254 | SDL_FreeSurface(_surface); |
| 255 | _alignedBuffer = 0; |
| 256 | _surface = 0; |
| 257 | |
| 258 | // SDL only takes UTF-8 filenames |
| 259 | // so here's an ugly hack to match this ugly reasoning |
| 260 | std::string utf8 = Language::wstrToUtf8(Language::fsToWstr(filename)); |
| 261 | |
| 262 | // Load file |
| 263 | _surface = IMG_Load(utf8.c_str()); |
| 264 | if (!_surface) |
| 265 | { |
| 266 | std::string err = filename + ":" + IMG_GetError(); |
| 267 | throw Exception(err); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * Loads the contents of an X-Com SPK image file into |
no test coverage detected