Skip to content

Commit d0d53de

Browse files
committed
* Fix image copying. Disable other options as they aren't implemented for now.
1 parent 6d4a05f commit d0d53de

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/resource.rc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ BEGIN
226226
POPUP "Dummy"
227227
BEGIN
228228
MENUITEM "Copy Image", ID_DUMMY_COPYIMAGE
229-
MENUITEM "Save Image", ID_DUMMY_SAVEIMAGE
229+
MENUITEM "Save Image", ID_DUMMY_SAVEIMAGE, INACTIVE
230230
MENUITEM SEPARATOR
231-
MENUITEM "Copy Image Link", ID_DUMMY_COPYIMAGELINK
232-
MENUITEM "Open Image Link", ID_DUMMY_OPENIMAGELINK
231+
MENUITEM "Copy Image Link", ID_DUMMY_COPYIMAGELINK, INACTIVE
232+
MENUITEM "Open Image Link", ID_DUMMY_OPENIMAGELINK, INACTIVE
233233
END
234234
END
235235

src/windows/ImageViewer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ LRESULT CALLBACK ImageViewerChildWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
258258
{
259259
case ID_DUMMY_COPYIMAGE:
260260
{
261-
HBITMAP bitmapCopy = (HBITMAP)ri::CopyImage(g_hBitmapFull->Frames[0].Bitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
261+
HBITMAP bitmapCopy = (HBITMAP)ri::CopyImage(g_hBitmapFull->Frames[0].Bitmap, IMAGE_BITMAP, 0, 0, 0);
262262
if (!bitmapCopy)
263263
break;
264264

@@ -514,13 +514,18 @@ bool RegisterImageViewerClass()
514514
return RegisterClass(&wc2) != 0;
515515
}
516516

517+
const char* trustedDiscordCdn = "https://cdn.discordapp.com/";
518+
517519
void CreateImageViewer(const std::string& proxyURL, const std::string& url, const std::string& fileName, int width, int height)
518520
{
519521
// Kill it if present:
520522
KillImageViewer();
521523

522-
g_ProxyURL = proxyURL;
524+
// just use the normal URL if it's from cdn.discordapp.com (as opposed to the other
525+
// CDN which jpeg-ifies images (I know it's webp but still loses lots of quality))
526+
bool useUrlAsProxyUrl = strncmp(url.c_str(), trustedDiscordCdn, strlen(trustedDiscordCdn)) == 0;
523527
g_FileName = fileName;
528+
g_ProxyURL = useUrlAsProxyUrl ? url : proxyURL;
524529
g_ActualURL = url;
525530

526531
LPCTSTR tstr = ConvertCppStringToTString(fileName);

0 commit comments

Comments
 (0)