From 45f076bd429c40d81607f43837f1cc571f3f6be0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Feb 2013 00:49:50 +0300 Subject: Improve a bit image load speed. --- src/resources/imagehelper.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/resources/imagehelper.cpp') diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index 5b7797cbb..eea15d29c 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -43,8 +43,7 @@ bool ImageHelper::mEnableAlpha = true; Image *ImageHelper::load(SDL_RWops *const rw) { - SDL_Surface *const tmpImage = IMG_Load_RW(rw, 1); - + SDL_Surface *const tmpImage = loadPng(rw); if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); @@ -115,3 +114,15 @@ void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image) const format->Gmask, format->Bmask, format->Amask); } } + +SDL_Surface *ImageHelper::loadPng(SDL_RWops *const rw) +{ + if (!rw || !IMG_isPNG(rw)) + { + logger->log("Error, image missing or not png"); + return nullptr; + } + SDL_Surface *const tmpImage = IMG_LoadPNG_RW(rw); + SDL_RWclose(rw); + return tmpImage; +} -- cgit v1.2.3-60-g2f50