1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix creating cursor image from AtlasTexture

This commit is contained in:
kleonc
2024-06-02 22:05:21 +02:00
parent 705b7a0b0b
commit 91e995e704
7 changed files with 29 additions and 70 deletions

View File

@@ -2831,8 +2831,7 @@ void DisplayServerMacOS::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();
@@ -2854,13 +2853,8 @@ void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor,
int len = int(texture_size.width * texture_size.height);
for (int i = 0; i < len; i++) {
int row_index = floor(i / texture_size.width) + atlas_rect.position.y;
int column_index = (i % int(texture_size.width)) + atlas_rect.position.x;
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);
}
int row_index = floor(i / texture_size.width);
int column_index = i % int(texture_size.width);
uint32_t color = image->get_pixel(column_index, row_index).to_argb32();