本文整理汇总了C++中BitMap::create_from_image_alpha方法的典型用法代码示例。如果您正苦于以下问题:C++ BitMap::create_from_image_alpha方法的具体用法?C++ BitMap::create_from_image_alpha怎么用?C++ BitMap::create_from_image_alpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMap
的用法示例。
在下文中一共展示了BitMap::create_from_image_alpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _edit_region
void TextureRegionEditor::_edit_region() {
Ref<Texture> texture = NULL;
if (node_sprite)
texture = node_sprite->get_texture();
else if (node_patch9)
texture = node_patch9->get_texture();
else if (obj_styleBox.is_valid())
texture = obj_styleBox->get_texture();
else if (atlas_tex.is_valid())
texture = atlas_tex->get_atlas();
if (texture.is_null()) {
return;
}
autoslice_cache.clear();
Ref<Image> i;
i.instance();
if (i->load(texture->get_path()) == OK) {
BitMap bm;
bm.create_from_image_alpha(i);
for (int y = 0; y < i->get_height(); y++) {
for (int x = 0; x < i->get_width(); x++) {
if (bm.get_bit(Point2(x, y))) {
bool found = false;
for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
Rect2 grown = E->get().grow(1.5);
if (grown.has_point(Point2(x, y))) {
E->get().expand_to(Point2(x, y));
E->get().expand_to(Point2(x + 1, y + 1));
x = E->get().position.x + E->get().size.x - 1;
bool merged = true;
while (merged) {
merged = false;
bool queue_erase = false;
for (List<Rect2>::Element *F = autoslice_cache.front(); F; F = F->next()) {
if (queue_erase) {
autoslice_cache.erase(F->prev());
queue_erase = false;
}
if (F == E)
continue;
if (E->get().grow(1).intersects(F->get())) {
E->get().expand_to(F->get().position);
E->get().expand_to(F->get().position + F->get().size);
if (F->prev()) {
F = F->prev();
autoslice_cache.erase(F->next());
} else {
queue_erase = true;
//Can't delete the first rect in the list.
}
merged = true;
}
}
}
found = true;
break;
}
}
if (!found) {
Rect2 new_rect(x, y, 1, 1);
autoslice_cache.push_back(new_rect);
}
}
}
}
}
if (node_sprite)
rect = node_sprite->get_region_rect();
else if (node_patch9)
rect = node_patch9->get_region_rect();
else if (obj_styleBox.is_valid())
rect = obj_styleBox->get_region_rect();
else if (atlas_tex.is_valid())
rect = atlas_tex->get_region();
edit_draw->update();
}