mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Working on benchmarking some of the code, and to integrate this into the core of Greenshot. [skip ci]
This commit is contained in:
parent
7702fe5f4f
commit
065149c9e0
41 changed files with 516 additions and 124 deletions
|
@ -10,5 +10,6 @@
|
|||
<add key="myget.dotnetcore" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="dotnet-core-latest" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="bdn-nightly" value="https://ci.appveyor.com/nuget/benchmarkdotnet" />
|
||||
</packageSources>
|
||||
</configuration>
|
10
build.cake
10
build.cake
|
@ -176,17 +176,23 @@ Task("AssemblyVersion")
|
|||
Task("EnableDNC30")
|
||||
.Does(() =>
|
||||
{
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<TargetFrameworks>.*</TargetFrameworks><!-- net471;netcoreapp3.0 -->", "<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>");
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<TargetFrameworks>.*</TargetFrameworks><!-- net472;netcoreapp3.0 -->", "<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>");
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<Project Sdk=\"MSBuild.Sdk.Extras/1.6.65\"><!-- Microsoft.NET.Sdk.WindowsDesktop -->", "<Project Sdk=\"Microsoft.NET.Sdk.WindowsDesktop\">");
|
||||
});
|
||||
|
||||
Task("DisableDNC30")
|
||||
.Does(() =>
|
||||
{
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>", "<TargetFrameworks>net471</TargetFrameworks><!-- net471;netcoreapp3.0 -->");
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>", "<TargetFrameworks>net472</TargetFrameworks><!-- net472;netcoreapp3.0 -->");
|
||||
ReplaceRegexInFiles("./**/*.csproj", "<Project Sdk=\"Microsoft.NET.Sdk.WindowsDesktop\">", "<Project Sdk=\"MSBuild.Sdk.Extras/1.6.65\"><!-- Microsoft.NET.Sdk.WindowsDesktop -->");
|
||||
});
|
||||
|
||||
Task("ChangeNETVersion")
|
||||
.Does(() =>
|
||||
{
|
||||
ReplaceRegexInFiles("./**/*.csproj", "net471", "net472");
|
||||
});
|
||||
|
||||
// Clean all unneeded files, so we build on a clean file system
|
||||
Task("Clean")
|
||||
.Does(() =>
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<PackageProjectUrl>https://github.com/greenshot/greenshot</PackageProjectUrl>
|
||||
<PackageLicenseUrl>https://www.gnu.org/licenses/gpl.html</PackageLicenseUrl>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<!-- <DisableImplicitFrameworkReferences Condition="'$(TargetFramework)' == 'net471'">true</DisableImplicitFrameworkReferences> -->
|
||||
<CopyLocalLockFileAssemblies Condition="'$(TargetFramework)' != 'net471'">true</CopyLocalLockFileAssemblies>
|
||||
<!-- <DisableImplicitFrameworkReferences Condition="'$(TargetFramework)' == 'net472'">true</DisableImplicitFrameworkReferences> -->
|
||||
<CopyLocalLockFileAssemblies Condition="'$(TargetFramework)' != 'net472'">true</CopyLocalLockFileAssemblies>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
<AssemblySearchPaths Condition="'$(TargetFramework)' == 'net471'">{HintPathFromItem};{TargetFrameworkDirectory};{RawFileName};{GAC};</AssemblySearchPaths>
|
||||
<AssemblySearchPaths Condition="'$(TargetFramework)' == 'net472'">{HintPathFromItem};{TargetFrameworkDirectory};{RawFileName};{GAC};</AssemblySearchPaths>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>false</UseWindowsForms>
|
||||
<OsProductName>$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@ProductName)</OsProductName>
|
||||
|
@ -48,8 +48,8 @@
|
|||
<DebugSymbols>True</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.38">
|
||||
<!--<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests'))">
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.105">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
@ -57,7 +57,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</ItemGroup>-->
|
||||
|
||||
<Target Name="PostBuild" BeforeTargets="PostBuildEvent" Condition="$(MSBuildProjectName.Contains('Addon.')) And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
|
||||
<Exec Command="
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Box</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Box</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Confluence</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Confluence</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Dropbox</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Dropbox</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.ExternalCommand</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.ExternalCommand</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Flickr</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Flickr</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.GooglePhotos</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.GooglePhotos</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Imgur</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Imgur</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
@ -55,6 +55,6 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0212" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Jira</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Jira</AssemblyName>
|
||||
<TargetFrameworks>net471</TargetFrameworks>
|
||||
<TargetFrameworks>net472</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.LegacyEditor</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.LegacyEditor</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Lutim</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Lutim</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
@ -51,7 +51,7 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.9" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0212" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.OCR</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.OCR</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net471</TargetFrameworks>
|
||||
<TargetFrameworks>net472</TargetFrameworks>
|
||||
<RootNamespace>Greenshot.Addon.OcrCommand</RootNamespace>
|
||||
<AssemblyName>GreenshotOCRCommand</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="CustomMarshalers" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Office</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Office</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.OneDrive</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.OneDrive</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
@ -51,7 +51,7 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.9" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0212" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Photobucket</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Photobucket</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Tfs</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Tfs</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -12,7 +12,7 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
|
@ -51,7 +51,7 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.9" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0212" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<RootNamespace>Greenshot.Addon.Win10</RootNamespace>
|
||||
<AssemblyName>Greenshot.Addon.Win10</AssemblyName>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -13,21 +13,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.3.0" />
|
||||
<Reference Include="Windows">
|
||||
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<!-- Light up Windows 10 features -->
|
||||
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="5.0.1" />
|
||||
<!--PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview1-27018-01" />-->
|
||||
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
|
||||
<Aliases>global</Aliases>
|
||||
</Reference>
|
||||
<Reference Include="Windows">
|
||||
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd</HintPath>
|
||||
</Reference>
|
||||
|
@ -62,5 +54,7 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.21" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.21" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.9" />
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview.19073.11" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="6.0.0-preview1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -40,24 +40,33 @@ namespace Greenshot.Addon.Win10
|
|||
|
||||
public void InitializeComponent(Form target)
|
||||
{
|
||||
// TODO: Fix the code below, when the following is solved: https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/16#issuecomment-451337186
|
||||
if (target is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
// InkCanvas
|
||||
inkCanvasHost = new WindowsXamlHost();
|
||||
inkCanvasHost.InitialTypeName = "Windows.UI.Xaml.Controls.InkCanvas";
|
||||
inkCanvasHost.ChildChanged += InkCanvas_ChildChanged;
|
||||
// InkToolbar
|
||||
inkToolbarHost = new WindowsXamlHost();
|
||||
inkToolbarHost.InitialTypeName = "Windows.UI.Xaml.Controls.InkToolbar";
|
||||
inkToolbarHost.ChildChanged += InkToolbar_ChildChanged;
|
||||
// Layout
|
||||
inkToolbarHost.Top = 0;
|
||||
inkToolbarHost.Left = 0;
|
||||
inkToolbarHost.Height = 50;
|
||||
inkToolbarHost.Dock = DockStyle.Top;
|
||||
inkCanvasHost = new WindowsXamlHost
|
||||
{
|
||||
InitialTypeName = "Windows.UI.Xaml.Controls.InkCanvas",
|
||||
Dock = DockStyle.Fill,
|
||||
BackColor = Color.Transparent,
|
||||
|
||||
inkCanvasHost.Dock = DockStyle.Fill;
|
||||
inkCanvasHost.BackColor = Color.Transparent;
|
||||
};
|
||||
inkCanvasHost.ChildChanged += InkCanvas_ChildChanged;
|
||||
|
||||
// InkToolbar
|
||||
inkToolbarHost = new WindowsXamlHost
|
||||
{
|
||||
InitialTypeName = "Windows.UI.Xaml.Controls.InkToolbar",
|
||||
// Layout
|
||||
Top = 0,
|
||||
Left = 0,
|
||||
Height = 50,
|
||||
Dock = DockStyle.Top,
|
||||
BackColor = Color.Transparent
|
||||
};
|
||||
inkToolbarHost.ChildChanged += InkToolbar_ChildChanged;
|
||||
|
||||
// Add to Window
|
||||
target.Controls.Add(inkToolbarHost);
|
||||
|
|
96
src/Greenshot.Addons/Core/DotNetScreenCapture.cs
Normal file
96
src/Greenshot.Addons/Core/DotNetScreenCapture.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom
|
||||
//
|
||||
// For more information see: http://getgreenshot.org/
|
||||
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
#region Usings
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Dapplo.Windows.Gdi32;
|
||||
using Dapplo.Windows.Gdi32.Enums;
|
||||
using Dapplo.Windows.Gdi32.SafeHandles;
|
||||
using Dapplo.Windows.Gdi32.Structs;
|
||||
using Dapplo.Windows.User32;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Addons.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// This allows us to repeatedly capture the screen via DotNet
|
||||
/// </summary>
|
||||
public class DotNetScreenCapture : IDisposable
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return the source rectangle
|
||||
/// </summary>
|
||||
public NativeRect SourceRect { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Return the source rectangle
|
||||
/// </summary>
|
||||
public NativeSize DestinationSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The constructor
|
||||
/// </summary>
|
||||
/// <param name="sourceCaptureBounds">NativeRect, optional, with the source area from the screen</param>
|
||||
/// <param name="requestedSize">NativeSize, optional, specifying the resulting size</param>
|
||||
public DotNetScreenCapture(NativeRect? sourceCaptureBounds = null, NativeSize? requestedSize = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capture a frame from the screen
|
||||
/// </summary>
|
||||
public void CaptureFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the frame, captured with the previous CaptureFrame call, as
|
||||
/// </summary>
|
||||
/// <returns>Bitmap</returns>
|
||||
public Bitmap CurrentFrameAsBitmap()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose all DC, DIB, handles etc
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
|||
<PackageReference Include="System.ComponentModel.Composition" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
@ -72,10 +72,10 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MahApps.Metro.IconPacks">
|
||||
<Version>3.0.0-alpha0096</Version>
|
||||
<Version>3.0.0-alpha0103</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Svg">
|
||||
<Version>2.4.0</Version>
|
||||
<Version>2.4.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
PixelStride = pixelStride,
|
||||
BitmapSize = destinationBitmap.Height * pixelStride
|
||||
};
|
||||
|
||||
if (isAlpha)
|
||||
{
|
||||
ApplyBoxBlurSpanAlpha(spanInfo, range);
|
||||
|
@ -150,10 +151,9 @@ namespace Greenshot.Gfx.Experimental
|
|||
|
||||
Parallel.For(spanInfo.Top, spanInfo.Bottom, y =>
|
||||
{
|
||||
Span<Rgb24> rgb24;
|
||||
unsafe { rgb24 = new Span<Rgb24>((byte*)spanInfo.Pointer, spanInfo.BitmapSize); }
|
||||
unsafe
|
||||
{
|
||||
|
||||
unsafe {
|
||||
var rgb24 = new Span<Rgb24>((byte*)spanInfo.Pointer, spanInfo.BitmapSize);
|
||||
Span<Rgb24> averages = stackalloc Rgb24[range];
|
||||
var r = 0;
|
||||
var g = 0;
|
||||
|
@ -217,10 +217,8 @@ namespace Greenshot.Gfx.Experimental
|
|||
var halfRange = range / 2;
|
||||
Parallel.For(spanInfo.Left, spanInfo.Right, x =>
|
||||
{
|
||||
Span<Rgb24> rgb24;
|
||||
unsafe { rgb24 = new Span<Rgb24>((byte*)spanInfo.Pointer, spanInfo.BitmapSize); }
|
||||
unsafe
|
||||
{
|
||||
unsafe {
|
||||
var rgb24 = new Span<Rgb24>((byte*)spanInfo.Pointer, spanInfo.BitmapSize);
|
||||
Span<Rgb24> averages = stackalloc Rgb24[range];
|
||||
var hits = 0;
|
||||
var r = 0;
|
||||
|
@ -228,7 +226,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
var b = 0;
|
||||
for (var y = spanInfo.Top; y < spanInfo.Top + halfRange; y++)
|
||||
{
|
||||
ref Rgb24 color = ref rgb24[x + y * spanInfo.PixelStride];
|
||||
ref Rgb24 color = ref rgb24[y * spanInfo.PixelStride + x];
|
||||
r += color.R;
|
||||
g += color.G;
|
||||
b += color.B;
|
||||
|
@ -257,7 +255,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
hits++;
|
||||
}
|
||||
|
||||
ref Rgb24 average = ref averages[(y % range)];
|
||||
ref Rgb24 average = ref averages[y % range];
|
||||
average.R = (byte)(r / hits);
|
||||
average.G = (byte)(g / hits);
|
||||
average.B = (byte)(b / hits);
|
||||
|
@ -285,19 +283,18 @@ namespace Greenshot.Gfx.Experimental
|
|||
|
||||
Parallel.For(spanInfo.Top, spanInfo.Bottom, y =>
|
||||
{
|
||||
Span<Bgra32> argb32;
|
||||
unsafe { argb32 = new Span<Bgra32>((byte*)spanInfo.Pointer, spanInfo.BitmapSize); }
|
||||
unsafe
|
||||
{
|
||||
unsafe {
|
||||
var argb32 = new Span<Bgra32>((byte*)spanInfo.Pointer, spanInfo.BitmapSize);
|
||||
Span<Bgra32> averages = stackalloc Bgra32[range];
|
||||
var a = 0;
|
||||
var r = 0;
|
||||
var g = 0;
|
||||
var b = 0;
|
||||
var hits = halfRange;
|
||||
var lineOffset = y * spanInfo.PixelStride;
|
||||
for (var x = spanInfo.Left; x < spanInfo.Left + halfRange; x++)
|
||||
{
|
||||
ref Bgra32 color = ref argb32[x + y * spanInfo.PixelStride];
|
||||
ref Bgra32 color = ref argb32[x + lineOffset];
|
||||
a += color.A;
|
||||
r += color.R;
|
||||
g += color.G;
|
||||
|
@ -309,7 +306,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
if (leftSide >= spanInfo.Left)
|
||||
{
|
||||
// Get value at the left side of range
|
||||
ref Bgra32 color = ref argb32[leftSide + y * spanInfo.PixelStride];
|
||||
ref Bgra32 color = ref argb32[leftSide + lineOffset];
|
||||
a -= color.A;
|
||||
r -= color.R;
|
||||
g -= color.G;
|
||||
|
@ -320,7 +317,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
var rightSide = x + halfRange;
|
||||
if (rightSide < spanInfo.Right)
|
||||
{
|
||||
ref Bgra32 color = ref argb32[rightSide + y * spanInfo.PixelStride];
|
||||
ref Bgra32 color = ref argb32[rightSide + lineOffset];
|
||||
a += color.A;
|
||||
r += color.R;
|
||||
g += color.G;
|
||||
|
@ -328,7 +325,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
hits++;
|
||||
}
|
||||
|
||||
ref Bgra32 average = ref averages[(x % range)];
|
||||
ref Bgra32 average = ref averages[x % range];
|
||||
average.A = (byte)(a / hits);
|
||||
average.R = (byte)(r / hits);
|
||||
average.G = (byte)(g / hits);
|
||||
|
@ -339,7 +336,7 @@ namespace Greenshot.Gfx.Experimental
|
|||
// Now we can write the value from the calculated avarages
|
||||
var readLocation = (leftSide % range);
|
||||
|
||||
argb32[leftSide + y * spanInfo.PixelStride] = averages[readLocation];
|
||||
argb32[leftSide + lineOffset] = averages[readLocation];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
|
49
src/Greenshot.Gfx.Experimental/Structs/Bgr32.cs
Normal file
49
src/Greenshot.Gfx.Experimental/Structs/Bgr32.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom
|
||||
//
|
||||
// For more information see: http://getgreenshot.org/
|
||||
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Gfx.Experimental.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// A struct with the BGR values for a 32bit pixel
|
||||
/// </summary>
|
||||
public struct Bgr32
|
||||
{
|
||||
/// <summary>
|
||||
/// Blue component of the pixel
|
||||
/// </summary>
|
||||
public byte B;
|
||||
/// <summary>
|
||||
/// Green component of the pixel
|
||||
/// </summary>
|
||||
public byte G;
|
||||
/// <summary>
|
||||
/// Red component of the pixel
|
||||
/// </summary>
|
||||
public byte R;
|
||||
/// <summary>
|
||||
/// Unused component of the pixel
|
||||
/// </summary>
|
||||
public readonly byte Unused;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,13 +24,25 @@
|
|||
namespace Greenshot.Gfx.Experimental.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default BGRA values for a 32bit bitmapsource
|
||||
/// A struct with the BGR values for a 32bit pixel
|
||||
/// </summary>
|
||||
public struct Bgra32
|
||||
{
|
||||
/// <summary>
|
||||
/// Blue component of the pixel
|
||||
/// </summary>
|
||||
public byte B;
|
||||
/// <summary>
|
||||
/// Green component of the pixel
|
||||
/// </summary>
|
||||
public byte G;
|
||||
/// <summary>
|
||||
/// Red component of the pixel
|
||||
/// </summary>
|
||||
public byte R;
|
||||
/// <summary>
|
||||
/// Alpha component of the pixel
|
||||
/// </summary>
|
||||
public byte A;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
namespace Greenshot.Gfx.Experimental.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// Default RGB values for a 24bit bitmap
|
||||
/// A struct with the BGR values for a 24bit pixel
|
||||
/// </summary>
|
||||
public struct Rgb24
|
||||
{
|
||||
/// <summary>
|
||||
/// Blue component of the pixel
|
||||
/// </summary>
|
||||
public byte B;
|
||||
/// <summary>
|
||||
/// Green component of the pixel
|
||||
/// </summary>
|
||||
public byte G;
|
||||
/// <summary>
|
||||
/// Red component of the pixel
|
||||
/// </summary>
|
||||
public byte R;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Greenshot.Gfx.Experimental.Structs
|
||||
{
|
||||
public struct SpanInfo
|
||||
public class SpanInfo
|
||||
{
|
||||
public IntPtr Pointer;
|
||||
public int PixelStride;
|
||||
|
|
149
src/Greenshot.Gfx.Experimental/UnmanagedBitmap.cs
Normal file
149
src/Greenshot.Gfx.Experimental/UnmanagedBitmap.cs
Normal file
|
@ -0,0 +1,149 @@
|
|||
#region Greenshot GNU General Public License
|
||||
|
||||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom
|
||||
//
|
||||
// For more information see: http://getgreenshot.org/
|
||||
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace Greenshot.Gfx.Experimental
|
||||
{
|
||||
/// <summary>
|
||||
/// A bitmap with memory from Marshal.AllocHGlobal
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixelLayout">struct for the pixel information</typeparam>
|
||||
public class UnmanagedBitmap<TPixelLayout> : MemoryManager<TPixelLayout> where TPixelLayout : unmanaged
|
||||
{
|
||||
private readonly object _lock = new object();
|
||||
private readonly int _byteLength;
|
||||
private readonly int _bytesPerPixel;
|
||||
private readonly int _stride;
|
||||
private bool _isDisposed;
|
||||
private readonly IntPtr _hGlobal;
|
||||
|
||||
/// <summary>
|
||||
/// Width of the bitmap
|
||||
/// </summary>
|
||||
public int Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of the bitmap
|
||||
/// </summary>
|
||||
public int Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The format of the pixels
|
||||
/// </summary>
|
||||
public PixelFormat Format { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for the UnmanagedBitmap
|
||||
/// </summary>
|
||||
/// <param name="width">int</param>
|
||||
/// <param name="height">int</param>
|
||||
/// <param name="pixelFormat">PixelFormat</param>
|
||||
public UnmanagedBitmap(int width, int height, PixelFormat pixelFormat)
|
||||
{
|
||||
_bytesPerPixel = Marshal.SizeOf<TPixelLayout>();
|
||||
Width = width;
|
||||
Height = height;
|
||||
Format = pixelFormat;
|
||||
_stride = width * _bytesPerPixel;
|
||||
_byteLength = height * _stride;
|
||||
_hGlobal = Marshal.AllocHGlobal(_byteLength);
|
||||
GC.AddMemoryPressure(_byteLength);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override unsafe Span<TPixelLayout> GetSpan() => new Span<TPixelLayout>(_hGlobal.ToPointer(), _byteLength);
|
||||
|
||||
/// <summary>
|
||||
/// Retrusn
|
||||
/// </summary>
|
||||
public override Memory<TPixelLayout> Memory => CreateMemory(0, Width * Height);
|
||||
|
||||
/// <summary>
|
||||
/// NotSupportedException
|
||||
/// </summary>
|
||||
/// <param name="elementIndex">int</param>
|
||||
/// <returns>MemoryHandle</returns>
|
||||
public override MemoryHandle Pin(int elementIndex = 0)
|
||||
{
|
||||
throw new NotSupportedException("Pinning not needed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NotSupportedException
|
||||
/// </summary>
|
||||
public override void Unpin()
|
||||
{
|
||||
throw new NotSupportedException("Pinning not needed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert this to a real bitmap
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap AsBitmap()
|
||||
{
|
||||
return new Bitmap(Width, Height, _stride, Format, _hGlobal);
|
||||
}
|
||||
|
||||
#region Implementation of IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose implementation
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_isDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock (_lock)
|
||||
{
|
||||
if (_isDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
Marshal.FreeHGlobal(_hGlobal);
|
||||
GC.RemoveMemoryPressure(_byteLength);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
|
@ -31,8 +31,9 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations">
|
||||
<Version>1.2.21</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0006" />
|
||||
<PackageReference Include="Svg">
|
||||
<Version>2.4.0</Version>
|
||||
<Version>2.4.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -5,6 +5,9 @@ using Greenshot.Gfx;
|
|||
using Greenshot.Gfx.Experimental;
|
||||
using Greenshot.Gfx.Quantizer;
|
||||
using Greenshot.Tests.Implementation;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace Greenshot.PerformanceTests
|
||||
{
|
||||
|
@ -14,6 +17,12 @@ namespace Greenshot.PerformanceTests
|
|||
[MinColumn, MaxColumn, MemoryDiagnoser]
|
||||
public class GfxPerformance
|
||||
{
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
BoxBlurImageSharp();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
[Arguments(PixelFormat.Format24bppRgb)]
|
||||
[Arguments(PixelFormat.Format32bppRgb)]
|
||||
|
@ -69,6 +78,21 @@ namespace Greenshot.PerformanceTests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Benchmark]
|
||||
public void BoxBlurImageSharp()
|
||||
{
|
||||
var color = NamedColors<Rgb24>.Blue;
|
||||
var solidBlueBrush = SixLabors.ImageSharp.Processing.Brushes.Solid(color);
|
||||
var graphicsOptions = new GraphicsOptions(false);
|
||||
using (var image = new Image<Rgb24>(SixLabors.ImageSharp.Configuration.Default, 400, 400, NamedColors<Rgb24>.White))
|
||||
{
|
||||
image.Mutate(c => c
|
||||
.Fill(new GraphicsOptions(false), solidBlueBrush, new SixLabors.Primitives.Rectangle(30, 30, 340, 340))
|
||||
.BoxBlur(10));
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
[Arguments(PixelFormat.Format24bppRgb)]
|
||||
[Arguments(PixelFormat.Format32bppRgb)]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<RootNamespace>Greenshot.PerformanceTests</RootNamespace>
|
||||
<AssemblyName>Greenshot.PerformanceTests</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
<PackageReference Include="System.Xml.ReaderWriter" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
@ -56,7 +56,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.3" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.4" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
||||
<PackageReference Include="JeremyAnsel.ColorQuant" Version="1.0.55" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
|
||||
|
@ -67,6 +67,8 @@
|
|||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
||||
<PackageReference Include="SharpAvi" Version="2.1.1" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0006" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0006" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.2" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Environments;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Running;
|
||||
|
||||
namespace Greenshot.PerformanceTests
|
||||
|
@ -37,10 +34,7 @@ namespace Greenshot.PerformanceTests
|
|||
// ReSharper disable once UnusedParameter.Local
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var job = Job.Default.With(Platform.X64);
|
||||
var config = DefaultConfig.Instance.With(job).KeepBenchmarkFiles(true);
|
||||
//BenchmarkRunner.Run<GfxPerformanceShort>(config);
|
||||
BenchmarkRunner.Run<CapturePerformance>(config);
|
||||
BenchmarkRunner.Run<GfxPerformance>();
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,13 @@
|
|||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using Greenshot.Gfx;
|
||||
using Greenshot.Gfx.Experimental;
|
||||
using Greenshot.Tests.Implementation;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using Xunit;
|
||||
|
||||
namespace Greenshot.Tests
|
||||
|
@ -35,6 +39,43 @@ namespace Greenshot.Tests
|
|||
/// </summary>
|
||||
public class BlurTests
|
||||
{
|
||||
[Fact]
|
||||
public void Test_BoxBlurSharpImage()
|
||||
{
|
||||
using (var bitmapOld = BitmapFactory.CreateEmpty(400, 400, PixelFormat.Format32bppArgb, Color.White))
|
||||
{
|
||||
using (var graphics = Graphics.FromImage(bitmapOld))
|
||||
using (var pen = new SolidBrush(Color.Blue))
|
||||
{
|
||||
graphics.FillRectangle(pen, new Rectangle(30, 30, 340, 340));
|
||||
bitmapOld.ApplyOldBoxBlur(10);
|
||||
bitmapOld.Save(@"old.png", ImageFormat.Png);
|
||||
}
|
||||
|
||||
using (var tmpStream = new MemoryStream())
|
||||
using (var image = new Image<Rgba32>(SixLabors.ImageSharp.Configuration.Default, 400, 400, Rgba32.White))
|
||||
{
|
||||
var color = Rgba32.Blue;
|
||||
color.A = 255;
|
||||
var solidBlueBrush = SixLabors.ImageSharp.Processing.Brushes.Solid(color);
|
||||
var g = new GraphicsOptions(false);
|
||||
image.Mutate(c => c
|
||||
.Fill(new GraphicsOptions(false), solidBlueBrush, new SixLabors.Primitives.Rectangle(30, 30, 340, 340))
|
||||
.BoxBlur(10));
|
||||
image.SaveAsPng(tmpStream);
|
||||
|
||||
tmpStream.Seek(0, SeekOrigin.Begin);
|
||||
using (var bitmapNew = (Bitmap)System.Drawing.Image.FromStream(tmpStream))
|
||||
{
|
||||
bitmapNew.Save(@"new.png", ImageFormat.Png);
|
||||
Assert.True(bitmapOld.IsEqualTo(bitmapNew), "New blur doesn't compare to old.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData(PixelFormat.Format24bppRgb)]
|
||||
[InlineData(PixelFormat.Format32bppRgb)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
<PackageReference Include="System.Xml.ReaderWriter" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
@ -67,7 +67,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.3" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.4" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.21" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
|
@ -78,6 +78,7 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0006" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||
|
@ -87,7 +88,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xunit.StaFact" Version="0.3.13" />
|
||||
<PackageReference Include="Xunit.StaFact" Version="0.3.18" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFrameworks>net471;netcoreapp3.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ApplicationIcon>icons\applicationIcon\icon.ico</ApplicationIcon>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<ApplicationManifest>greenshot.manifest</ApplicationManifest>
|
||||
<AssemblyTitle>Greenshot</AssemblyTitle>
|
||||
<AssemblyName>Greenshot</AssemblyName>
|
||||
<RuntimeIdentifiers>win-x86</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -35,7 +36,7 @@
|
|||
<PackageReference Include="System.ServiceModel.Syndication" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
|
@ -96,8 +97,8 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="2.0.0-alpha0106" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha0096" />
|
||||
<PackageReference Include="Svg" Version="2.4.0" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha0103" />
|
||||
<PackageReference Include="Svg" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -55,8 +55,8 @@ namespace Greenshot
|
|||
// Specify the directories for the translations manually, this is a workaround
|
||||
builder.Register(context => LanguageConfigBuilder.Create()
|
||||
.WithSpecificDirectories(GenerateScanDirectories(
|
||||
#if NET471
|
||||
"net471",
|
||||
#if NET472
|
||||
"net472",
|
||||
#else
|
||||
"netcoreapp3.0",
|
||||
#endif
|
||||
|
|
6
src/NuGet.Config
Normal file
6
src/NuGet.Config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
Loading…
Add table
Add a link
Reference in a new issue