16 bool MaskPickInfo::load(
const std::string& _file)
18 if (!DataManager::getInstance().isDataExist(_file))
21 RenderManager& render = RenderManager::getInstance();
22 ITexture* texture = render.createTexture(_file);
23 texture->loadFromFile(_file);
25 uint8* buffer = (
uint8*)texture->lock(TextureUsage::Read);
26 if (buffer ==
nullptr)
28 render.destroyTexture(texture);
32 size_t pixel_size = texture->getNumElemBytes();
34 mWidth = texture->getWidth();
35 mHeight = texture->getHeight();
36 size_t size = mWidth * mHeight;
40 for (
size_t pos_pix = 0; pos_pix < size; pos_pix++)
43 for (
size_t in_pix = 0; in_pix < pixel_size; in_pix++)
45 if (0xFF != buffer[pos])
52 mData[pos_pix] = white;
56 render.destroyTexture(texture);
61 bool MaskPickInfo::pick(
const IntPoint& _point,
const IntCoord& _coord)
const
63 if ((0 == _coord.width) || (0 == _coord.height))
66 int x = ((_point.left * mWidth) - 1) / _coord.width;
67 int y = ((_point.top * mHeight) - 1) / _coord.height;
69 return 0 != mData[(size_t)(y * mWidth + x)];
72 bool MaskPickInfo::empty()
const
types::TPoint< int > IntPoint
types::TCoord< int > IntCoord