Browse Source

ep_weather: Draw weather icon element directly instead of through createImageBitmap (#4545)

pull/4568/head
Amrsatrio 3 months ago
parent
commit
6959c699d9
  1. 11
      ep_gui/GUI.c
  2. 18
      ep_weather_host/ep_weather_provider_google_script.h

11
ep_gui/GUI.c

@ -2558,16 +2558,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) @@ -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;

18
ep_weather_host/ep_weather_provider_google_script.h

@ -296,13 +296,11 @@ function ep_weather_utf8ToHex(str) {\n\ @@ -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\ @@ -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\ @@ -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\

Loading…
Cancel
Save