MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / loadImage

Method loadImage

src/Engine/Surface.cpp:250–269  ·  view source on GitHub ↗

* Loads the contents of an image file of a * known format into the surface. * @param filename Filename of the image. */

Source from the content-addressed store, hash-verified

248 * @param filename Filename of the image.
249 */
250void 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

Callers 2

loadMethod · 0.80
XcomResourcePackMethod · 0.80

Calls 2

DeleteAlignedFunction · 0.85
ExceptionClass · 0.85

Tested by

no test coverage detected