| 68 | } |
| 69 | |
| 70 | void* BaseManager::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename) |
| 71 | { |
| 72 | std::string fullname = MyGUI::OpenGLDataManager::getInstance().getDataPath(_filename); |
| 73 | void* result = nullptr; |
| 74 | SDL_Surface* image = nullptr; |
| 75 | SDL_Surface* cvtImage = nullptr; // converted surface with RGBA/RGB pixel format |
| 76 | image = IMG_Load(fullname.c_str()); |
| 77 | MYGUI_ASSERT(image != nullptr, "Failed to load image: " + fullname); |
| 78 | |
| 79 | _width = image->w; |
| 80 | _height = image->h; |
| 81 | |
| 82 | int bpp = image->format->BytesPerPixel; |
| 83 | if (bpp < 3) |
| 84 | { |
| 85 | result = convertPixelData(image, _format); |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | Uint32 pixelFmt = bpp == 3 ? SDL_PIXELFORMAT_BGR24 : SDL_PIXELFORMAT_ARGB8888; |
| 90 | cvtImage = SDL_ConvertSurfaceFormat(image, pixelFmt, 0); |
| 91 | result = convertPixelData(cvtImage, _format); |
| 92 | SDL_FreeSurface(cvtImage); |
| 93 | } |
| 94 | SDL_FreeSurface(image); |
| 95 | |
| 96 | return result; |
| 97 | } |
| 98 | |
| 99 | void BaseManager::saveImage( |
| 100 | int _width, |
no test coverage detected