From 6959c699d9cdcddf387e3dad9c8f7dd014710c88 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Fri, 12 Sep 2025 18:58:39 +0700 Subject: [PATCH] ep_weather: Draw weather icon element directly instead of through createImageBitmap (#4545) --- ep_gui/GUI.c | 11 +---------- .../ep_weather_provider_google_script.h | 18 +++++------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index dce30db..03d2dfb 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -2558,16 +2558,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) if (IsWindows11Build25346OrHigher()) { // Hide the win8 network flyout as an option on Win 11 after 25346 as van.dll was removed - MENUITEMINFOA menuInfo; - ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA)); - menuInfo.cbSize = sizeof(MENUITEMINFOA); - menuInfo.fMask = MIIM_DATA; - GetMenuItemInfoA(hMenu, 3, FALSE, &menuInfo); - if (menuInfo.dwItemData) - { - free(menuInfo.dwItemData); - } - RemoveMenu(hMenu, 3, MF_BYCOMMAND); + GUI_RemoveChoiceEntry(hMenu, 2); // Windows 8 flyout } } HKEY hKey = NULL; diff --git a/ep_weather_host/ep_weather_provider_google_script.h b/ep_weather_host/ep_weather_provider_google_script.h index d4d61c1..b303e46 100644 --- a/ep_weather_host/ep_weather_provider_google_script.h +++ b/ep_weather_host/ep_weather_provider_google_script.h @@ -296,13 +296,11 @@ function ep_weather_utf8ToHex(str) {\n\ encodeURIComponent(c).replace(/\\%%/g,'').toLowerCase()\n\ ).join('');\n\ }\n\ -function ep_weather_drawImageToCanvas(image) {\n\ +function ep_weather_drawImageToCanvas(image, w, h) {\n\ const canvas = document.createElement('canvas');\n\ - const w = image.width;\n\ - const h = image.height;\n\ canvas.width = w;\n\ canvas.height = h;\n\ - canvas.getContext('2d').drawImage(image, 0, 0);\n\ + canvas.getContext('2d').drawImage(image, 0, 0, w, h);\n\ return canvas;\n\ }\n\ function ep_weather_toHexString (byteArray) {\n\ @@ -322,8 +320,8 @@ function ep_weather_toHexString (byteArray) {\n\ //return chars.toString('utf8');\n\ return String.fromCharCode.apply(null, chars);\n\ }\n\ -function ep_weather_getData(imageBitmap, ch) {\n\ - const canvas = ep_weather_drawImageToCanvas(imageBitmap);\n\ +function ep_weather_getData(image, w, h, ch) {\n\ + const canvas = ep_weather_drawImageToCanvas(image, w, h);\n\ const ctx = canvas.getContext('2d');\n\ \n\ let result = [];\n\ @@ -358,13 +356,7 @@ if (!unit.includes(p)) {\n\ Array.from(document.getElementsByClassName('wob-unit')[0].getElementsByTagName('a')).filter(e => e.className == 'wob_t').filter(e => e.innerText.includes(p))[0].click();\n\ unit = 'x';\n\ }\n\ -createImageBitmap(\n\ - (final_im != 0) ? final_im : document.getElementsByClassName(\"YQ4gaf zr758c\")[0], \n\ - { resizeWidth: %d, resizeHeight: %d, resizeQuality: 'high' }\n\ -)\n\ -.then(imageBitmap => \n\ - ep_result = ep_weather_getData(imageBitmap, unit)\n\ -);\n\ +ep_result = ep_weather_getData(\n\(final_im != 0) ? final_im : document.getElementsByClassName(\"YQ4gaf zr758c\")[0], %d, %d, unit);\n\ function ep_weather_part1() {\n\ return \"run_part_2\";\n\ }\n\