完成分离effect

This commit is contained in:
Xu Liu 2021-07-01 19:04:02 +08:00
commit 2b35420ea8
28 changed files with 265 additions and 231 deletions

View file

@ -46,7 +46,7 @@
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
@ -132,6 +132,8 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View file

@ -46,7 +46,7 @@
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
@ -132,6 +132,8 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -141,6 +143,9 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\EffectCommon\EffectCommon.vcxproj">
<Project>{95c6c401-ae29-4b29-b1a7-20782f0937d1}</Project>
</ProjectReference>
<ProjectReference Include="..\MODULE_ACNet\MODULE_ACNet.vcxproj">
<Project>{340bc8c2-c2b0-434c-be5e-76d640cbca85}</Project>
</ProjectReference>

View file

@ -44,14 +44,17 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Utility</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -83,6 +86,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -147,6 +151,8 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -154,6 +160,15 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<FxCompile>
<ShaderType>Pixel</ShaderType>
</FxCompile>
<FxCompile>
<ShaderModel>5.0</ShaderModel>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileOutput>$(OutDir)\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CommonDebug.h" />

View file

@ -28,17 +28,25 @@ public:
return S_OK;
}
static HRESULT ReadScaleProp(const nlohmann::json& props, std::pair<float, float>& scale) {
static HRESULT ReadScaleProp(
const nlohmann::json& props,
float fillScale,
const std::pair<float, float>& scale,
std::pair<float, float>& result
) {
if (!props.is_array() || props.size() != 2 || !props[0].is_number() || !props[1].is_number()) {
return E_INVALIDARG;
}
std::pair<float, float> result = { props[0], props[1] };
if (result.first == 0 || result.second == 0) {
std::pair<float, float> origin = { props[0], props[1] };
if (origin.first == 0 || origin.second == 0) {
return E_INVALIDARG;
}
scale = result;
result = {
origin.first > 0 ? origin.first : -origin.first * fillScale / scale.first,
origin.second > 0 ? origin.second : -origin.second * fillScale / scale.second
};
return S_OK;
}

View file

@ -25,7 +25,7 @@ protected:
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == NULL) {
if (hFile == INVALID_HANDLE_VALUE) {
CommonDebug::WriteLine(L"´ò¿ª\""s + path + L"\"ʧ°Ü");
return E_FAIL;
}

View file

@ -10,8 +10,9 @@ API_DECLSPEC HRESULT CreateEffect(
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_ACNET_EFFECT, isRegistered);
@ -33,6 +34,7 @@ API_DECLSPEC HRESULT CreateEffect(
}
effect = std::move(result);
scale = { 2.0f, 2.0f };
scale.first *= 2;
scale.second *= 2;
return S_OK;
}

View file

@ -45,7 +45,8 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -86,6 +87,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\effects\</OutDir>
<TargetName>ACNet</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -145,8 +148,8 @@
<ShaderType>Pixel</ShaderType>
<ShaderModel>5.0</ShaderModel>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<DisableOptimizations>true</DisableOptimizations>
<EnableDebuggingInformation>true</EnableDebuggingInformation>
<DisableOptimizations>false</DisableOptimizations>
<EnableDebuggingInformation>false</EnableDebuggingInformation>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
@ -160,6 +163,9 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalIncludeDirectories>$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -168,6 +174,23 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<FxCompile>
<DisableOptimizations>false</DisableOptimizations>
</FxCompile>
<FxCompile>
<EnableDebuggingInformation>false</EnableDebuggingInformation>
</FxCompile>
<FxCompile>
<ShaderType>Pixel</ShaderType>
</FxCompile>
<FxCompile>
<ShaderModel>5.0</ShaderModel>
</FxCompile>
<FxCompile>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ACNetEffect.h" />

View file

@ -68,7 +68,8 @@ HRESULT CreateAnime4KEffect(
}
effect = std::move(result);
scale = { 2.0f,2.0f };
scale.first *= 2;
scale.second *= 2;
return S_OK;
}
@ -77,8 +78,7 @@ HRESULT CreateDarkLinesEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_ANIME4K_DARKLINES_EFFECT, isRegistered);
@ -119,8 +119,6 @@ HRESULT CreateDarkLinesEffect(
}
effect = std::move(result);
scale = { 1.0f,1.0f };
return S_OK;
}
@ -128,8 +126,7 @@ HRESULT CreateThinLinesEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_ANIME4K_THINLINES_EFFECT, isRegistered);
@ -170,8 +167,6 @@ HRESULT CreateThinLinesEffect(
}
effect = std::move(result);
scale = { 1.0f,1.0f };
return S_OK;
}
@ -179,8 +174,7 @@ HRESULT CreateDenoiseBilateralEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_ANIME4K_DENOISE_BILATERAL_EFFECT, isRegistered);
@ -246,8 +240,6 @@ HRESULT CreateDenoiseBilateralEffect(
}
effect = std::move(result);
scale = { 1.0f,1.0f };
return S_OK;
}
@ -257,19 +249,20 @@ API_DECLSPEC HRESULT CreateEffect(
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
const auto& e = props.value("effect", "");
if (e == "Anime4K") {
return CreateAnime4KEffect(d2dFactory, d2dDC, props, effect, scale);
} else if (e == "darkLines") {
return CreateDarkLinesEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateDarkLinesEffect(d2dFactory, d2dDC, props, effect);
} else if (e == "thinLines") {
return CreateThinLinesEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateThinLinesEffect(d2dFactory, d2dDC, props, effect);
} else if (e == "denoiseBilateral") {
return CreateDenoiseBilateralEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateDenoiseBilateralEffect(d2dFactory, d2dDC, props, effect);
} else {
return E_INVALIDARG;
}
}
}

View file

@ -45,7 +45,8 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -85,6 +86,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>Anime4K</TargetName>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\effects\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -143,6 +146,8 @@
<ShaderModel>5.0</ShaderModel>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
<DisableOptimizations>false</DisableOptimizations>
<EnableDebuggingInformation>false</EnableDebuggingInformation>
</FxCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -155,6 +160,9 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalIncludeDirectories>$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -163,6 +171,14 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<FxCompile>
<ShaderType>Pixel</ShaderType>
<ShaderModel>5.0</ShaderModel>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<DisableOptimizations>false</DisableOptimizations>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Anime4KConvReduceTransform.h" />

View file

@ -14,8 +14,7 @@ API_DECLSPEC HRESULT CreateSharpenEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
ComPtr<ID2D1Effect>& effect
) {
ComPtr<ID2D1Effect> result;
HRESULT hr = d2dDC->CreateEffect(CLSID_D2D1Sharpen, &result);
@ -62,7 +61,6 @@ API_DECLSPEC HRESULT CreateSharpenEffect(
}
effect = std::move(result);
scale = { 1.0f,1.0f };
return S_OK;
}
@ -70,8 +68,7 @@ API_DECLSPEC HRESULT CreateAdaptiveSharpenEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_ADAPTIVE_SHARPEN_EFFECT, isRegistered);
@ -112,7 +109,6 @@ API_DECLSPEC HRESULT CreateAdaptiveSharpenEffect(
}
effect = std::move(result);
scale = { 1.0f,1.0f };
return S_OK;
}
@ -120,8 +116,9 @@ API_DECLSPEC HRESULT CreateLanczosEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_LANCZOS_SCALE_EFFECT, isRegistered);
@ -146,12 +143,15 @@ API_DECLSPEC HRESULT CreateLanczosEffect(
// scale 属性
auto it = props.find("scale");
if (it != props.end()) {
hr = EffectUtils::ReadScaleProp(*it, scaleResult);
hr = EffectUtils::ReadScaleProp(*it, fillScale, scale, scaleResult);
if (FAILED(hr)) {
return hr;
}
hr = result->SetValue(LanczosScaleEffect::PROP_SCALE, scaleResult);
hr = result->SetValue(
LanczosScaleEffect::PROP_SCALE,
D2D1_VECTOR_2F{ scaleResult.first, scaleResult.second }
);
if (FAILED(hr)) {
return hr;
}
@ -166,7 +166,7 @@ API_DECLSPEC HRESULT CreateLanczosEffect(
}
float ARStrength = value.get<float>();
if (ARStrength < 0 || ARStrength>1) {
if (ARStrength < 0 || ARStrength > 1) {
return E_INVALIDARG;
}
@ -177,7 +177,8 @@ API_DECLSPEC HRESULT CreateLanczosEffect(
}
effect = std::move(result);
scale = scaleResult;
scale.first *= scaleResult.first;
scale.second *= scaleResult.second;
return S_OK;
}
@ -185,8 +186,9 @@ API_DECLSPEC HRESULT CreateMitchellEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_MITCHELL_NETRAVALI_SCALE_EFFECT, isRegistered);
@ -211,12 +213,15 @@ API_DECLSPEC HRESULT CreateMitchellEffect(
// scale 属性
auto it = props.find("scale");
if (it != props.end()) {
hr = EffectUtils::ReadScaleProp(*it, scaleResult);
hr = EffectUtils::ReadScaleProp(*it, fillScale, scale, scaleResult);
if (FAILED(hr)) {
return hr;
}
hr = result->SetValue(MitchellNetravaliScaleEffect::PROP_SCALE, scaleResult);
hr = result->SetValue(
MitchellNetravaliScaleEffect::PROP_SCALE,
D2D1_VECTOR_2F{ scaleResult.first, scaleResult.second }
);
if (FAILED(hr)) {
return hr;
}
@ -237,7 +242,8 @@ API_DECLSPEC HRESULT CreateMitchellEffect(
}
effect = std::move(result);
scale = scaleResult;
scale.first *= scaleResult.first;
scale.second *= scaleResult.second;
return S_OK;
}
@ -279,33 +285,37 @@ API_DECLSPEC HRESULT CreatePixelScaleEffect(
return E_INVALIDARG;
}
hr = result->SetValue(PixelScaleEffect::PROP_SCALE, scale);
hr = result->SetValue(PixelScaleEffect::PROP_SCALE, scaleResult);
if (FAILED(hr)) {
return hr;
}
}
effect = std::move(result);
scale = { float(scaleResult), float(scaleResult) };
scale.first *= scaleResult;
scale.second *= scaleResult;
return S_OK;
}
API_DECLSPEC HRESULT CreateEffect(
ID2D1Factory1* d2dFactory,
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
const auto& e = props.value("effect", "");
if (e == "sharpen") {
return CreateSharpenEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateSharpenEffect(d2dFactory, d2dDC, props, effect);
} else if (e == "adaptiveSharpen") {
return CreateAdaptiveSharpenEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateAdaptiveSharpenEffect(d2dFactory, d2dDC, props, effect);
} else if (e == "lanczos") {
return CreateLanczosEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateLanczosEffect(d2dFactory, d2dDC, props, fillScale, scale, effect);
} else if (e == "mitchell") {
return CreateMitchellEffect(d2dFactory, d2dDC, props, effect, scale);
return CreateMitchellEffect(d2dFactory, d2dDC, props, fillScale, scale, effect);
} else if (e == "pixelScale") {
return CreatePixelScaleEffect(d2dFactory, d2dDC, props, effect, scale);
} else {

View file

@ -45,7 +45,8 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -85,6 +86,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\effects\</OutDir>
<TargetName>Common</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -147,6 +150,8 @@
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
<DisableOptimizations>false</DisableOptimizations>
<EnableDebuggingInformation>false</EnableDebuggingInformation>
</FxCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -159,6 +164,9 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalIncludeDirectories>$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -167,6 +175,17 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<FxCompile>
<ShaderType>Pixel</ShaderType>
</FxCompile>
<FxCompile>
<ShaderModel>5.0</ShaderModel>
</FxCompile>
<FxCompile>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AdaptiveSharpenEffect.h" />

View file

@ -58,7 +58,8 @@ HRESULT CreateLiteEffect(
}
effect = std::move(result);
scale = { 2.0f,2.0f };
scale.first *= 2;
scale.second *= 2;
return S_OK;
}
@ -67,8 +68,9 @@ HRESULT CreateZoomEffect(
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
bool isRegistered;
HRESULT hr = EffectUtils::IsEffectRegistered(d2dFactory, CLSID_MAGPIE_RAVU_ZOOM_EFFECT, isRegistered);
@ -89,32 +91,40 @@ HRESULT CreateZoomEffect(
return hr;
}
std::pair<float, float> scaleResult{ 1.0f,1.0f };
std::pair<float, float> scaleResult(1.0f, 1.0f);
// scale 属性
auto it = props.find("scale");
if (it != props.end()) {
hr = EffectUtils::ReadScaleProp(*it, scaleResult);
hr = EffectUtils::ReadScaleProp(*it, fillScale, scale, scaleResult);
if (FAILED(hr)) {
return hr;
}
hr = result->SetValue(RAVUZoomEffect::PROP_SCALE, scaleResult);
hr = result->SetValue(RAVUZoomEffect::PROP_SCALE, D2D1_VECTOR_2F{ scaleResult.first, scaleResult.second });
if (FAILED(hr)) {
return hr;
}
}
// 设置权重纹理
HBITMAP hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_RAVU_ZOOM_R3_WEIGHTS));
HBITMAP hBmp = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, 0);
if (hBmp == NULL) {
auto a = GetLastError();
return E_FAIL;
}
ComPtr<ID2D1Bitmap> weights;
hr = EffectUtils::LoadBitmapFromHBmp(wicImgFactory, d2dDC, hBmp, weights);
if (FAILED(hr)) {
return hr;
}
if (!DeleteObject(hBmp)) {
return E_FAIL;
}
result->SetInput(1, weights.Get());
effect = std::move(result);
scale = scaleResult;
scale.first *= scaleResult.first;
scale.second *= scaleResult.second;
return S_OK;
}
@ -124,14 +134,15 @@ API_DECLSPEC HRESULT CreateEffect(
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
) {
const auto& e = props.value("effect", "");
if (e == "lite") {
return CreateLiteEffect(d2dFactory, d2dDC, props, effect, scale);
} else if (e == "zoom") {
return CreateZoomEffect(d2dFactory, d2dDC, wicImgFactory, props, effect, scale);
return CreateZoomEffect(d2dFactory, d2dDC, wicImgFactory, props, fillScale, scale, effect);
} else {
return E_INVALIDARG;
}

View file

@ -47,10 +47,10 @@ END
/////////////////////////////////////////////////////////////////////////////
//
// PNG
// Bitmap
//
IDB_RAVU_ZOOM_R3_WEIGHTS PNG "RAVUZoomR3Weights.png"
IDB_BITMAP1 BITMAP "RavuZoomR3Weights.bmp"
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////

View file

@ -45,7 +45,8 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PreferredToolArchitecture>
</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -81,10 +82,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\effects\</OutDir>
<TargetName>RAUV</TargetName>
<TargetName>RAVU</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)build\$(Platform)\$(Configuration)\effects\</OutDir>
<TargetName>RAVU</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -157,6 +160,9 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -165,6 +171,13 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<FxCompile>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ShaderModel>5.0</ShaderModel>
<ShaderType>Pixel</ShaderType>
<CompileD2DCustomEffect>true</CompileD2DCustomEffect>
<ObjectFileOutput>$(OutDir)\..\shaders\%(Filename).cso</ObjectFileOutput>
</FxCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="EffectDefines.h" />
@ -203,7 +216,7 @@
<ResourceCompile Include="MODULE_RAVU.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="RAVUZoomR3Weights.png" />
<Image Include="RavuZoomR3Weights.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -69,12 +69,12 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EFFECT_RAVU.rc">
<ResourceCompile Include="MODULE_RAVU.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="RAVUZoomR3Weights.png">
<Image Include="RavuZoomR3Weights.bmp">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

@ -1,15 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 EFFECT_RAVU.rc 使用
// 供 MODULE_RAVU.rc 使用
//
#define IDB_RAVU_ZOOM_R3_WEIGHTS 101
#define IDB_BITMAP1 106
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif

View file

@ -29,91 +29,49 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8FC22A64-6D09-478B-9980-608D27601EF2}.Debug|x64.ActiveCfg = Debug|x64
{8FC22A64-6D09-478B-9980-608D27601EF2}.Debug|x64.Build.0 = Debug|x64
{8FC22A64-6D09-478B-9980-608D27601EF2}.Debug|x86.ActiveCfg = Debug|Win32
{8FC22A64-6D09-478B-9980-608D27601EF2}.Debug|x86.Build.0 = Debug|Win32
{8FC22A64-6D09-478B-9980-608D27601EF2}.Release|x64.ActiveCfg = Release|x64
{8FC22A64-6D09-478B-9980-608D27601EF2}.Release|x64.Build.0 = Release|x64
{8FC22A64-6D09-478B-9980-608D27601EF2}.Release|x86.ActiveCfg = Release|Win32
{8FC22A64-6D09-478B-9980-608D27601EF2}.Release|x86.Build.0 = Release|Win32
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Debug|x64.ActiveCfg = Debug|x64
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Debug|x64.Build.0 = Debug|x64
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Debug|x86.ActiveCfg = Debug|x86
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Debug|x86.Build.0 = Debug|x86
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Release|x64.ActiveCfg = Release|x64
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Release|x64.Build.0 = Release|x64
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Release|x86.ActiveCfg = Release|x86
{C75EC8D6-FF40-4307-9B46-EA760DC5E4C9}.Release|x86.Build.0 = Release|x86
{983647DC-E3C2-4658-852B-FF4D146F8134}.Debug|x64.ActiveCfg = Debug|x64
{983647DC-E3C2-4658-852B-FF4D146F8134}.Debug|x64.Build.0 = Debug|x64
{983647DC-E3C2-4658-852B-FF4D146F8134}.Debug|x86.ActiveCfg = Debug|x86
{983647DC-E3C2-4658-852B-FF4D146F8134}.Debug|x86.Build.0 = Debug|x86
{983647DC-E3C2-4658-852B-FF4D146F8134}.Release|x64.ActiveCfg = Release|x64
{983647DC-E3C2-4658-852B-FF4D146F8134}.Release|x64.Build.0 = Release|x64
{983647DC-E3C2-4658-852B-FF4D146F8134}.Release|x86.ActiveCfg = Release|x86
{983647DC-E3C2-4658-852B-FF4D146F8134}.Release|x86.Build.0 = Release|x86
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Debug|x64.ActiveCfg = Debug|x64
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Debug|x64.Build.0 = Debug|x64
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Debug|x86.ActiveCfg = Debug|Win32
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Debug|x86.Build.0 = Debug|Win32
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Release|x64.ActiveCfg = Release|x64
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Release|x64.Build.0 = Release|x64
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Release|x86.ActiveCfg = Release|Win32
{340BC8C2-C2B0-434C-BE5E-76D640CBCA85}.Release|x86.Build.0 = Release|Win32
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Debug|x64.ActiveCfg = Debug|x64
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Debug|x64.Build.0 = Debug|x64
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Debug|x86.ActiveCfg = Debug|Win32
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Debug|x86.Build.0 = Debug|Win32
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Release|x64.ActiveCfg = Release|x64
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Release|x64.Build.0 = Release|x64
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Release|x86.ActiveCfg = Release|Win32
{898BAE76-BE0D-43A0-88F0-1DDA502363F5}.Release|x86.Build.0 = Release|Win32
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Debug|x64.ActiveCfg = Debug|x64
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Debug|x64.Build.0 = Debug|x64
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Debug|x86.ActiveCfg = Debug|Win32
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Debug|x86.Build.0 = Debug|Win32
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Release|x64.ActiveCfg = Release|x64
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Release|x64.Build.0 = Release|x64
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Release|x86.ActiveCfg = Release|Win32
{95C6C401-AE29-4B29-B1A7-20782F0937D1}.Release|x86.Build.0 = Release|Win32
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Debug|x64.ActiveCfg = Debug|x64
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Debug|x64.Build.0 = Debug|x64
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Debug|x86.ActiveCfg = Debug|Win32
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Debug|x86.Build.0 = Debug|Win32
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Release|x64.ActiveCfg = Release|x64
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Release|x64.Build.0 = Release|x64
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Release|x86.ActiveCfg = Release|Win32
{FD3ED999-21E0-4F6A-AB78-F37E2466A356}.Release|x86.Build.0 = Release|Win32
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Debug|x64.ActiveCfg = Debug|x64
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Debug|x64.Build.0 = Debug|x64
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Debug|x86.ActiveCfg = Debug|Win32
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Debug|x86.Build.0 = Debug|Win32
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Release|x64.ActiveCfg = Release|x64
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Release|x64.Build.0 = Release|x64
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Release|x86.ActiveCfg = Release|Win32
{E5A19099-F4B4-48ED-89DB-43A3F1FCF8AE}.Release|x86.Build.0 = Release|Win32
{EC100169-8050-440A-96F0-3AC8B9382F30}.Debug|x64.ActiveCfg = Debug|x64
{EC100169-8050-440A-96F0-3AC8B9382F30}.Debug|x64.Build.0 = Debug|x64
{EC100169-8050-440A-96F0-3AC8B9382F30}.Debug|x86.ActiveCfg = Debug|Win32
{EC100169-8050-440A-96F0-3AC8B9382F30}.Debug|x86.Build.0 = Debug|Win32
{EC100169-8050-440A-96F0-3AC8B9382F30}.Release|x64.ActiveCfg = Release|x64
{EC100169-8050-440A-96F0-3AC8B9382F30}.Release|x64.Build.0 = Release|x64
{EC100169-8050-440A-96F0-3AC8B9382F30}.Release|x86.ActiveCfg = Release|Win32
{EC100169-8050-440A-96F0-3AC8B9382F30}.Release|x86.Build.0 = Release|Win32
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Debug|x64.ActiveCfg = Debug|x64
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Debug|x64.Build.0 = Debug|x64
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Debug|x86.ActiveCfg = Debug|Win32
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Debug|x86.Build.0 = Debug|Win32
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Release|x64.ActiveCfg = Release|x64
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Release|x64.Build.0 = Release|x64
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Release|x86.ActiveCfg = Release|Win32
{D2E9F2FF-D5B3-4C4E-BE17-D5409B814743}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -66,14 +66,14 @@ namespace Magpie.Properties {
/// &quot;name&quot;: &quot;通用Lanczos&quot;,
/// &quot;model&quot;: [
/// {
/// &quot;effect&quot;: &quot;scale&quot;,
/// &quot;type&quot;: &quot;lanczos&quot;,
/// &quot;scale&quot;: [ 0, 0 ],
/// &quot;module&quot;: &quot;Common&quot;,
/// &quot;effect&quot;: &quot;lanczos&quot;,
/// &quot;scale&quot;: [ -1, -1 ],
/// &quot;ARStrength&quot;: 0.7
/// },
/// {
/// &quot;effect&quot;: &quot;sharpen&quot;,
/// &quot;type&quot;: &quot;adaptive&quot;,
/// &quot;module&quot;: &quot;Common&quot;,
/// &quot;effect&quot;: &quot;adaptiveSharpen&quot;,
/// &quot;curveHeight&quot;: 0.8
/// }
/// ]
@ -82,13 +82,13 @@ namespace Magpie.Properties {
/// &quot;name&quot;: &quot;通用RAVU&quot;,
/// &quot;model&quot;: [
/// {
/// &quot;effect&quot;: &quot;scale&quot;,
/// &quot;type&quot;: &quot;ravuZoom&quot;,
/// &quot;scale&quot;: [ 0, 0 ]
/// &quot;module&quot;: &quot;RAVU&quot;,
/// &quot;effect&quot;: &quot;zoom&quot;,
/// &quot;scale&quot;: [ -1, -1 ]
/// },
/// {
/// &quot;effect&quot;: &quot;misc&quot;,
/// &quot;type&quot;: &quot;Anime4KDen [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// &quot;module&quot;: &quot;Anime4K&quot;,
/// &quot;eff [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string BuiltInScaleModels {
get {

View file

@ -123,14 +123,14 @@
"name": "通用Lanczos",
"model": [
{
"effect": "scale",
"type": "lanczos",
"scale": [ 0, 0 ],
"module": "Common",
"effect": "lanczos",
"scale": [ -1, -1 ],
"ARStrength": 0.7
},
{
"effect": "sharpen",
"type": "adaptive",
"module": "Common",
"effect": "adaptiveSharpen",
"curveHeight": 0.8
}
]
@ -139,13 +139,13 @@
"name": "通用RAVU",
"model": [
{
"effect": "scale",
"type": "ravuZoom",
"scale": [ 0, 0 ]
"module": "RAVU",
"effect": "zoom",
"scale": [ -1, -1 ]
},
{
"effect": "misc",
"type": "Anime4KDenoiseBilateral",
"module": "Anime4K",
"effect": "denoiseBilateral",
"variant": "mode"
}
]
@ -154,13 +154,12 @@
"name": "动漫 2xACNet",
"model": [
{
"effect": "scale",
"type": "ACNet"
"module": "ACNet"
},
{
"effect": "scale",
"type": "mitchell",
"scale": [ 0, 0 ],
"module": "Common",
"effect": "mitchell",
"scale": [ -1, -1 ],
"useSharperVersion": true
}
]
@ -169,15 +168,15 @@
"name": "动漫 2xAnime4K",
"model": [
{
"effect": "scale",
"type": "Anime4K",
"module": "Anime4K",
"effect": "Anime4K",
"curveHeight": 0.3,
"useDenoiseVersion": true
},
{
"effect": "scale",
"type": "mitchell",
"scale": [ 0, 0 ],
"module": "Common",
"effect": "mitchell",
"scale": [ -1, -1 ],
"useSharperVersion": true
}
]
@ -186,58 +185,36 @@
"name": "动漫 2xAnime4K+ThinLines",
"model": [
{
"effect": "scale",
"type": "Anime4K",
"module": "Anime4K",
"effect": "Anime4K",
"curveHeight": 0.6,
"useDenoiseVersion": true
},
{
"effect": "scale",
"type": "mitchell",
"scale": [ 0, 0 ],
"useSharperVersion": true
"module": "Common",
"effect": "mitchell",
"scale": [ -1, -1 ],
"useSharperVersion": true
},
{
"effect": "misc",
"type": "Anime4KThinLines",
"module": "Anime4K",
"effect": "thinLines",
"strength": 0.3
},
{
"module": "Common",
"effect": "sharpen",
"type": "builtIn",
"sharpness": 1,
"threshold": 0.3
}
]
},
{
"name": "动漫 4xAnime4K x2",
"model": [
{
"effect": "scale",
"type": "Anime4K",
"curveHeight": 0.3,
"useDenoiseVersion": true
},
{
"effect": "scale",
"type": "Anime4K",
"curveHeight": 0.3
},
{
"effect": "scale",
"type": "mitchell",
"scale": [ 0, 0 ],
"useSharperVersion": true
}
]
},
{
"name": "像素 2x",
"model": [
{
"effect": "scale",
"type": "pixel",
"module": "Common",
"effect": "pixelScale",
"scale": 2
}
]
@ -246,21 +223,11 @@
"name": "像素 3x",
"model": [
{
"effect": "scale",
"type": "pixel",
"module": "Common",
"effect": "pixelScale",
"scale": 3
}
]
},
{
"name": "像素 4x",
"model": [
{
"effect": "scale",
"type": "pixel",
"scale": 4
}
]
}
]</value>
</data>

View file

@ -228,8 +228,8 @@ private:
HCURSOR result = CreateCursor(
Env::$instance->GetHInstance(),
min(hotSpot.first, _cursorSize.cx),
min(hotSpot.second, _cursorSize.cy),
std::min(hotSpot.first, (int)_cursorSize.cx),
std::min(hotSpot.second, (int)_cursorSize.cy),
_cursorSize.cx, _cursorSize.cy,
andPlane, xorPlane
);

View file

@ -11,8 +11,9 @@ using EffectCreateFunc = HRESULT(
ID2D1DeviceContext* d2dDC,
IWICImagingFactory2* wicImgFactory,
const nlohmann::json& props,
ComPtr<ID2D1Effect>& effect,
std::pair<float, float>& scale
float fillScale,
std::pair<float, float>& scale,
ComPtr<ID2D1Effect>& effect
);
@ -25,6 +26,11 @@ public:
_d2dDC(Env::$instance->GetD2DDC()),
_d2dFactory(Env::$instance->GetD2DFactory())
{
SIZE hostSize = Utils::GetSize(Env::$instance->GetHostClient());
SIZE srcSize = Utils::GetSize(Env::$instance->GetSrcClient());
// 输出图像充满屏幕时的缩放比例
_fillScale = std::min(float(hostSize.cx) / srcSize.cx, float(hostSize.cy) / srcSize.cy);
}
virtual ~EffectRendererBase() {}
@ -61,6 +67,7 @@ private:
Debug::Assert(model.is_object(), L"json 格式错误");
const auto &moduleName = model.value("module", "");
Debug::Assert(moduleName.size() > 0, L"json 格式错误");
std::wstring moduleNameW;
Debug::ThrowIfComFailed(
@ -74,40 +81,22 @@ private:
Debug::ThrowIfWin32Failed(createEffect, L"非法的dll");
ComPtr<ID2D1Effect> effect;
std::pair<float, float> scale;
Debug::ThrowIfComFailed(
createEffect(_d2dFactory, _d2dDC, Env::$instance->GetWICImageFactory(), model, effect, scale),
createEffect(_d2dFactory, _d2dDC, Env::$instance->GetWICImageFactory(), model, _fillScale, _scale, effect),
L"json格式错误"
);
// 替换 output effect
_PushAsOutputEffect(effect);
_UpdateScale(scale);
}
}
void _UpdateScale(std::pair<float, float> scale) {
if (scale.first == 0 || scale.second == 0) {
SIZE hostSize = Utils::GetSize(Env::$instance->GetHostClient());
SIZE srcSize = Utils::GetSize(Env::$instance->GetSrcClient());
// Êä³öͼÏñ³äÂúÆÁÄ»
float x = float(hostSize.cx) / srcSize.cx / _scale.first;
float y = float(hostSize.cy) / srcSize.cy / _scale.second;
scale.first = min(x, y);
scale.second = scale.first;
}
_scale.first *= scale.first;
_scale.second *= scale.second;
}
private:
// 输出图像尺寸
std::pair<float, float> _scale{ 1.0f,1.0f };
float _fillScale = 0;
ID2D1Factory1* _d2dFactory;
ID2D1DeviceContext* _d2dDC;
};

View file

@ -46,6 +46,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -53,6 +54,7 @@
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture />
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -174,6 +176,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalIncludeDirectories>$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -185,7 +188,7 @@
</Version>
</Link>
<FxCompile>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(WindowsSDK_IncludePath);$(SolutionDir)\EffectCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</FxCompile>
<FxCompile>
<ShaderType>Pixel</ShaderType>

View file

@ -161,8 +161,7 @@ public:
return E_FAIL;
}
result = std::move(r);
result = std::wstring(r.begin(), r.begin() + convertResult);
return S_OK;
}
};

View file

@ -7,6 +7,7 @@
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
#define OEMRESOURCE // 需要设置系统光标 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor
#define NOMINMAX // 使用标准库的min和max而不是宏
// Windows 头文件
#include <windows.h>

View file

@ -1,3 +1,3 @@
TEXTURE.txt
out.txt
*.png
*.bmp

View file

@ -3,7 +3,7 @@ import imageio
import numpy as np
IN_FILE = 'TEXTURE.txt'
OUT_FILE = 'RavuZoomR3Weights.png'
OUT_FILE = 'RavuZoomR3Weights.bmp'
weights: np.ndarray = resolve(IN_FILE)