MCPcopy Create free account
hub / github.com/MyGUI/mygui / loadImage

Method loadImage

Common/Base/OpenGLES/BaseManager.cpp:78–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

getDataPathMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected