Merge pull request #92702 from kleonc/cursor_image_from_atlas_texture_fix
Fix creating cursor image from `AtlasTexture`
This commit is contained in:
commit
e52658643d
7 changed files with 29 additions and 70 deletions
|
|
@ -2408,8 +2408,7 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
|
|||
cursors_cache.erase(p_shape);
|
||||
}
|
||||
|
||||
Rect2 atlas_rect;
|
||||
Ref<Image> image = _get_cursor_image_from_resource(p_cursor, p_hotspot, atlas_rect);
|
||||
Ref<Image> image = _get_cursor_image_from_resource(p_cursor, p_hotspot);
|
||||
ERR_FAIL_COND(image.is_null());
|
||||
Vector2i texture_size = image->get_size();
|
||||
|
||||
|
|
@ -2437,13 +2436,9 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
|
|||
|
||||
bool fully_transparent = true;
|
||||
for (UINT index = 0; index < image_size; index++) {
|
||||
int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
|
||||
int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
|
||||
int row_index = floor(index / texture_size.width);
|
||||
int column_index = index % int(texture_size.width);
|
||||
|
||||
if (atlas_rect.has_area()) {
|
||||
column_index = MIN(column_index, atlas_rect.size.width - 1);
|
||||
row_index = MIN(row_index, atlas_rect.size.height - 1);
|
||||
}
|
||||
const Color &c = image->get_pixel(column_index, row_index);
|
||||
fully_transparent = fully_transparent && (c.a == 0.f);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue