From 1f0cf81f5710073eb6174161028956da4b78005e Mon Sep 17 00:00:00 2001
From: Faycal ElOuariachi <faycal.eloua@gmail.com>
Date: Mon, 12 Feb 2024 13:14:11 +0100
Subject: [PATCH] Fix the fetching of images in CF_DIB format in
 DisplayServerWindows::clipboard_get_image

Fix the fetching of images from windows clipboard, if they're in CF_DIB format (e. g. by taking screenshots).

Image::create_from_data was used with an instance of Image, but it's a static function, returning a new instance.
(cherry picked from commit c1ec0360e9ba65df1eec788f56c9d9fd7ac14b9b)
---
 platform/windows/display_server_windows.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index fe9724b7f6e..8dd07a0bded 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -554,8 +554,7 @@ Ref<Image> DisplayServerWindows::clipboard_get_image() const {
 						pba.append(rgbquad->rgbReserved);
 					}
 				}
-				image.instantiate();
-				image->create_from_data(info->biWidth, info->biHeight, false, Image::Format::FORMAT_RGBA8, pba);
+				image = Image::create_from_data(info->biWidth, info->biHeight, false, Image::Format::FORMAT_RGBA8, pba);
 
 				GlobalUnlock(mem);
 			}