Remove size restriction for mouse cursor
This commit is contained in:
parent
1c81775f8a
commit
0988796f3c
|
@ -1199,9 +1199,7 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
|||
Ref<ImageTexture> texture = p_cursor;
|
||||
Image image = texture->get_data();
|
||||
|
||||
int image_size = 32 * 32;
|
||||
|
||||
ERR_FAIL_COND(texture->get_width() != 32 || texture->get_height() != 32);
|
||||
ERR_FAIL_COND(texture->get_width() > 256 || texture->get_height() > 256);
|
||||
|
||||
NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:NULL
|
||||
|
|
|
@ -1982,24 +1982,23 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
|
|||
Ref<ImageTexture> texture = p_cursor;
|
||||
Image image = texture->get_data();
|
||||
|
||||
UINT image_size = 32 * 32;
|
||||
UINT image_size = texture->get_width() * texture->get_height();
|
||||
UINT size = sizeof(UINT) * image_size;
|
||||
|
||||
ERR_FAIL_COND(texture->get_width() != 32 || texture->get_height() != 32);
|
||||
ERR_FAIL_COND(texture->get_width() > 256 || texture->get_height() > 256);
|
||||
|
||||
// Create the BITMAP with alpha channel
|
||||
COLORREF *buffer = (COLORREF *)malloc(sizeof(COLORREF) * image_size);
|
||||
|
||||
for (UINT index = 0; index < image_size; index++) {
|
||||
int column_index = floor(index / 32);
|
||||
int row_index = index % 32;
|
||||
int row_index = floor(index / texture->get_width());
|
||||
int column_index = index % texture->get_width();
|
||||
|
||||
Color pcColor = image.get_pixel(row_index, column_index);
|
||||
*(buffer + index) = image.get_pixel(row_index, column_index).to_ARGB32();
|
||||
*(buffer + index) = image.get_pixel(column_index, row_index).to_ARGB32();
|
||||
}
|
||||
|
||||
// Using 4 channels, so 4 * 8 bits
|
||||
HBITMAP bitmap = CreateBitmap(32, 32, 1, 4 * 8, buffer);
|
||||
HBITMAP bitmap = CreateBitmap(texture->get_width(), texture->get_height(), 1, 4 * 8, buffer);
|
||||
COLORREF clrTransparent = -1;
|
||||
|
||||
// Create the AND and XOR masks for the bitmap
|
||||
|
|
|
@ -2165,11 +2165,11 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
|||
Ref<ImageTexture> texture = p_cursor;
|
||||
Image image = texture->get_data();
|
||||
|
||||
ERR_FAIL_COND(texture->get_width() != 32 || texture->get_height() != 32);
|
||||
ERR_FAIL_COND(texture->get_width() > 256 || texture->get_height() > 256);
|
||||
|
||||
// Create the cursor structure
|
||||
XcursorImage *cursor_image = XcursorImageCreate(texture->get_width(), texture->get_height());
|
||||
XcursorUInt image_size = 32 * 32;
|
||||
XcursorUInt image_size = texture->get_width() * texture->get_height();
|
||||
XcursorDim size = sizeof(XcursorPixel) * image_size;
|
||||
|
||||
cursor_image->version = 1;
|
||||
|
@ -2181,10 +2181,10 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
|||
cursor_image->pixels = (XcursorPixel *)malloc(size);
|
||||
|
||||
for (XcursorPixel index = 0; index < image_size; index++) {
|
||||
int column_index = floor(index / 32);
|
||||
int row_index = index % 32;
|
||||
int row_index = floor(index / texture->get_width());
|
||||
int column_index = index % texture->get_width();
|
||||
|
||||
*(cursor_image->pixels + index) = image.get_pixel(row_index, column_index).to_ARGB32();
|
||||
*(cursor_image->pixels + index) = image.get_pixel(column_index, row_index).to_ARGB32();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(cursor_image->pixels == NULL);
|
||||
|
|
Loading…
Reference in New Issue