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

Method load

MyGUIEngine/src/MyGUI_MaskPickInfo.cpp:16–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14{
15
16 bool MaskPickInfo::load(const std::string& _file)
17 {
18 if (!DataManager::getInstance().isDataExist(_file))
19 return false;
20
21 RenderManager& render = RenderManager::getInstance();
22 ITexture* texture = render.createTexture(_file);
23 texture->loadFromFile(_file);
24
25 uint8* buffer = (uint8*)texture->lock(TextureUsage::Read);
26 if (buffer == nullptr)
27 {
28 render.destroyTexture(texture);
29 return false;
30 }
31
32 size_t pixel_size = texture->getNumElemBytes();
33
34 mWidth = texture->getWidth();
35 mHeight = texture->getHeight();
36 size_t size = mWidth * mHeight;
37 mData.resize(size);
38
39 size_t pos = 0;
40 for (size_t pos_pix = 0; pos_pix < size; pos_pix++)
41 {
42 bool white = true;
43 for (size_t in_pix = 0; in_pix < pixel_size; in_pix++)
44 {
45 if (0xFF != buffer[pos])
46 {
47 white = false;
48 }
49 pos++;
50 }
51
52 mData[pos_pix] = white;
53 }
54
55 texture->unlock();
56 render.destroyTexture(texture);
57
58 return true;
59 }
60
61 bool MaskPickInfo::pick(const IntPoint& _point, const IntCoord& _coord) const
62 {

Callers

nothing calls this directly

Calls 10

isDataExistMethod · 0.45
createTextureMethod · 0.45
loadFromFileMethod · 0.45
lockMethod · 0.45
destroyTextureMethod · 0.45
getNumElemBytesMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
resizeMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected