diff --git a/src/SKIV.cpp b/src/SKIV.cpp index 83b940c..1378bf1 100644 --- a/src/SKIV.cpp +++ b/src/SKIV.cpp @@ -851,7 +851,7 @@ void SKIF_Initialize (LPWSTR lpCmdLine) << "\n| > user data | " << _path_cache.skiv_userdata << "\n+------------------+-------------------------------------+"; - // SKIV also uses a folder to temporary internet files + // SKIV also uses a folder to temporary files const std::wstring tempDir = std::wstring (_path_cache.app_data_local.path) + LR"(\Temp\skiv\)"; @@ -908,6 +908,12 @@ void SKIF_Initialize (LPWSTR lpCmdLine) FindClose (hFind); } } + + // Create the folder for temporary files + else { + std::error_code ec; + std::filesystem::create_directories (_path_cache.skiv_temp, ec); + } } bool bKeepWindowAlive = true, @@ -1795,10 +1801,24 @@ wWinMain ( _In_ HINSTANCE hInstance, } } - //SKIF_ImGui_OptImage (SKIV_DesktopImage, vDesktopSize, ImVec2 (-1024.0f, -1024.0f), - // ImVec2 (-2048.0f, -2048.0f)); + SKIF_ImGui_OptImage (SKIV_DesktopImage, vDesktopSize, ImVec2 (-1024.0f, -1024.0f), + ImVec2 (-2048.0f, -2048.0f)); + + extern uint32_t SKIV_HDR_VisualizationId; + extern float SKIV_HDR_SDRWhite; + extern float SKIV_HDR_MaxCLL; + extern float SKIV_HDR_MaxLuminance; + extern float SKIV_HDR_DisplayMaxLuminance; + extern float SKIV_HDR_BrightnessScale; + + //SKIV_HDR_VisualizationId = SKIV_HDR_VISUALIZTION_GAMUT; + //SKIV_HDR_SDRWhite = 0.0f; + //SKIV_HDR_MaxCLL = 0.0f; + //SKIV_HDR_MaxLuminance = 0.0f; + //SKIV_HDR_DisplayMaxLuminance = 0.0f; + //SKIV_HDR_BrightnessScale = 0.1f; - SKIF_ImGui_OptImage (SKIV_DesktopImage, vDesktopSize); + //SKIF_ImGui_OptImage (SKIV_DesktopImage, vDesktopSize); //ImDrawList* draw_list = // ImGui::GetForegroundDrawList (); @@ -2064,8 +2084,8 @@ wWinMain ( _In_ HINSTANCE hInstance, PLOG_VERBOSE << "DirectX::CopyRectangle ( ): SUCCEEDED"; extern bool - SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped); - if (SKIV_Image_CopyToClipboard (subrect.GetImages (), true)) + SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped, bool isHDR); + if (SKIV_Image_CopyToClipboard (subrect.GetImages (), true, (_registry.iHDRMode > 0 && SKIF_Util_IsHDRActive ( )))) PLOG_VERBOSE << "SKIV_Image_CopyToClipboard ( ): SUCCEEDED"; else PLOG_WARNING << "SKIV_Image_CopyToClipboard ( ): FAILED"; diff --git a/src/tabs/viewer.cpp b/src/tabs/viewer.cpp index 1724d33..d666f75 100644 --- a/src/tabs/viewer.cpp +++ b/src/tabs/viewer.cpp @@ -572,7 +572,12 @@ static int getTextureLoadQueuePos (void) { } // External declaration -extern void SKIF_Shell_AddJumpList (std::wstring name, std::wstring path, std::wstring parameters, std::wstring directory, std::wstring icon_path, bool bService); +extern void SKIF_Shell_AddJumpList (std::wstring name, std::wstring path, std::wstring parameters, std::wstring directory, std::wstring icon_path, bool bService); + +// Forward declarations +bool SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped, bool isHDR); +HRESULT SKIF_Image_SaveToDisk_HDR (const DirectX::Image& image, const wchar_t* wszFileName); +HRESULT SKIF_Image_SaveToDisk_SDR (const DirectX::Image& image, const wchar_t* wszFileName); // Functions / Structs @@ -1474,9 +1479,7 @@ SKIF_UI_Tab_DrawViewer (void) SUCCEEDED (DirectX::CopyRectangle (*captured_img.GetImages (), src_rect, *subrect.GetImages (), DirectX::TEX_FILTER_DEFAULT, 0, 0))) { - extern bool - SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped); - if (SKIV_Image_CopyToClipboard (subrect.GetImages (), true)) + if (SKIV_Image_CopyToClipboard (subrect.GetImages (), true, cover.is_hdr)) { ImGui::InsertNotification ( { @@ -1492,6 +1495,7 @@ SKIF_UI_Tab_DrawViewer (void) copyRect = { 0,0,0,0 }; } + else { ImGui::InsertNotification ( { @@ -1510,9 +1514,7 @@ SKIF_UI_Tab_DrawViewer (void) else { - extern bool - SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped); - if (SKIV_Image_CopyToClipboard (captured_img.GetImages (), false)) + if (SKIV_Image_CopyToClipboard (captured_img.GetImages (), false, cover.is_hdr)) { ImGui::InsertNotification ( { @@ -1522,6 +1524,7 @@ SKIF_UI_Tab_DrawViewer (void) } ); } + else { ImGui::InsertNotification ( { @@ -3113,9 +3116,6 @@ SKIF_UI_Tab_DrawViewer (void) DirectX::ScratchImage captured_img; if (SUCCEEDED (DirectX::CaptureTexture (pDevice, pDevCtx, pCoverRes, captured_img))) { - HRESULT SKIF_Image_SaveToDisk_HDR (const DirectX::Image& image, const wchar_t* wszFileName); - HRESULT SKIF_Image_SaveToDisk_SDR (const DirectX::Image& image, const wchar_t* wszFileName); - if (cover.is_hdr) { hr = @@ -3254,8 +3254,6 @@ SKIF_UI_Tab_DrawViewer (void) DirectX::ScratchImage captured_img; if (SUCCEEDED (DirectX::CaptureTexture (pDevice, pDevCtx, pCoverRes, captured_img))) { - HRESULT SKIF_Image_SaveToDisk_HDR (const DirectX::Image& image, const wchar_t* wszFileName); - HRESULT SKIF_Image_SaveToDisk_SDR (const DirectX::Image& image, const wchar_t* wszFileName); if (cover.is_hdr) { @@ -4289,7 +4287,7 @@ SK_WIC_SetMaximumQuality (IPropertyBag2 *props) bool SKIV_HDR_SavePNGToDisk (const wchar_t* wszPNGPath, const DirectX::Image* png_image, const DirectX::Image* raw_image, - const char* szUtf8MetadataTitle) + const char* szUtf8MetadataTitle, bool isHDR) { if ( wszPNGPath == nullptr || png_image == nullptr || @@ -4318,9 +4316,8 @@ SKIV_HDR_SavePNGToDisk (const wchar_t* wszPNGPath, const DirectX::Image* png_ima { PLOG_VERBOSE << "DirectX::SaveToWICFile ( ): SUCCEEDED"; - return (png_image->format == DXGI_FORMAT_R16G16B16A16_UNORM) - ? SKIV_PNG_MakeHDR (wszPNGPath, *png_image, *raw_image) - : true; + return (isHDR) ? SKIV_PNG_MakeHDR (wszPNGPath, *png_image, *raw_image) + : true; } else PLOG_VERBOSE << "DirectX::SaveToWICFile ( ): FAILED"; @@ -4375,28 +4372,40 @@ void SKIV_HandleCopyShortcut (void) CComPtr SKIV_DesktopImage; -bool SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped) +bool SKIV_Image_CopyToClipboard (const DirectX::Image* pImage, bool snipped, bool isHDR) { if (pImage == nullptr) return false; - DirectX::ScratchImage hdr10_img; - if (SKIV_HDR_ConvertImageToPNG (*pImage, hdr10_img)) - { - PLOG_VERBOSE << "SKIV_HDR_ConvertImageToPNG ( ): TRUE"; + static SKIF_CommonPathsCache& _path_cache = SKIF_CommonPathsCache::GetInstance ( ); + + std::wstring wsPNGPath = _path_cache.skiv_temp; + wsPNGPath += snipped ? L"SKIV_Snip" + : L"SKIV_Clipboard"; + wsPNGPath += L".png"; + + PLOG_VERBOSE << wsPNGPath; - wchar_t wszPNGPath [MAX_PATH + 2] = { }; - GetCurrentDirectoryW (MAX_PATH, wszPNGPath); + if (isHDR) + { + if (SUCCEEDED (SKIF_Image_SaveToDisk_HDR (*pImage, wsPNGPath.c_str()))) + { + PLOG_VERBOSE << "SKIF_Image_SaveToDisk_HDR ( ): SUCCEEDED"; - PathAppendW (wszPNGPath, snipped ? L"SKIV_HDR_Snip" - : L"SKIV_HDR_Clipboard"); - PathAddExtensionW (wszPNGPath, L".png"); + if (SKIV_PNG_CopyToClipboard (*pImage, wsPNGPath.c_str(), 0)) + { + PLOG_VERBOSE << "SKIV_PNG_CopyToClipboard ( ): TRUE"; + return true; + } + } + } - if (SKIV_HDR_SavePNGToDisk (wszPNGPath, hdr10_img.GetImages (), pImage, nullptr)) + else { + if (SUCCEEDED (SKIF_Image_SaveToDisk_SDR (*pImage, wsPNGPath.c_str()))) { - PLOG_VERBOSE << "SKIV_HDR_SavePNGToDisk ( ): TRUE"; + PLOG_VERBOSE << "SKIF_Image_SaveToDisk_SDR ( ): SUCCEEDED"; - if (SKIV_PNG_CopyToClipboard (*hdr10_img.GetImage (0,0,0), wszPNGPath, 0)) + if (SKIV_PNG_CopyToClipboard (*pImage, wsPNGPath.c_str(), 0)) { PLOG_VERBOSE << "SKIV_PNG_CopyToClipboard ( ): TRUE"; return true; @@ -4917,7 +4926,7 @@ SKIF_Image_SaveToDisk_HDR (const DirectX::Image& image, const wchar_t* wszFileNa DirectX::ScratchImage png_img; if (SKIV_HDR_ConvertImageToPNG (image, png_img)) { - if (SKIV_HDR_SavePNGToDisk (wszImplicitFileName, png_img.GetImages (), &image, nullptr)) + if (SKIV_HDR_SavePNGToDisk (wszImplicitFileName, png_img.GetImages (), &image, nullptr, true)) { return S_OK; }