diff --git a/src/client/client.cpp b/src/client/client.cpp index 264a9f276..5eb2e54de 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -59,6 +59,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "game.h" #include "chatmessage.h" #include "translation.h" +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ +#include +#endif extern gui::IGUIEnvironment* guienv; @@ -694,6 +697,39 @@ bool Client::loadMedia(const std::string &data, const std::string &filename, return false; } +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + if (SDL_GetSystemRAM() < 2048) { + core::dimension2du dimensions = img->getDimension(); + irr::video::ECOLOR_FORMAT format = img->getColorFormat(); + irr::video::ECOLOR_FORMAT new_format = irr::video::ECF_UNKNOWN; + + if (format == irr::video::ECF_R8G8B8) { + new_format = irr::video::ECF_R5G6B5; + } else if (format == irr::video::ECF_A8R8G8B8) { + bool can_convert = true; + + u32 data_size = img->getImageDataSizeInBytes(); + u8 *data = (u8*) img->getData(); + for (u32 i = 0; i < data_size; i += 4) { + u8 alpha = data[i + 3]; + if (alpha > 0 && alpha < 255) { + can_convert = false; + break; + } + } + + if (can_convert) + new_format = irr::video::ECF_A1R5G5B5; + } + + if (new_format != irr::video::ECF_UNKNOWN) { + irr::video::IImage* converted_img = vdrv->createImage(new_format, dimensions); + img->copyTo(converted_img, core::position2d(0, 0)); + img->drop(); + img = converted_img; + } + } +#endif m_tsrc->insertSourceImage(filename, img); img->drop(); rfile->drop();