Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
koszeggy committed Jul 10, 2022
2 parents b104c75 + a45c8ad commit 76b4cf9
Show file tree
Hide file tree
Showing 91 changed files with 3,569 additions and 670 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/AlphaGradientDefault8bppWhiteA16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/Information4A16_WPF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/InformationWu4SilverA16DitheredB8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/ShieldBgr555BlackDitheredFS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/ShieldBgr555_WPF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/Images/ShieldRgb24_WPF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Help/KGySoft.Drawing.chm
Binary file not shown.
11 changes: 8 additions & 3 deletions KGySoft.Drawing.Core.UnitTest/GlobalInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#region Usings

#if !WINDOWS && (NET5_0 || NET6_0)
using System;
#endif

using NUnit.Framework;

#endregion
Expand All @@ -30,12 +34,13 @@ public class GlobalInitialization
[OneTimeSetUp]
public void Initialize()
{
#if !WINDOWS && (NET5_0 || NET6_0)
AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
#endif

#if NET7_0_OR_GREATER && !WINDOWS
Assert.Inconclusive("When targeting .NET 7 or later, executing the tests require Windows. For Unix systems target .NET 6 or earlier.");
#endif

// To make sure that System.Drawing types can be used also on Unix systems
DrawingModule.Initialize();
}

#endregion
Expand Down
1 change: 1 addition & 0 deletions KGySoft.Drawing.Core.UnitTest/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Style", "IDE0017:Simplify object initialization", Justification = "Decided individually")]
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Validated by global initialization")]
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Decided individually")]
[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "Decided individually")]
33 changes: 30 additions & 3 deletions KGySoft.Drawing.Core.UnitTest/KGySoft.Drawing.Core.UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!--<TargetFrameworks>net35;net40;net45;net46;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>-->
<TargetFrameworks>net45;net6.0</TargetFrameworks>
<TargetFrameworks>net35;net40;net45;net46;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<!--<TargetFrameworks>net6.0</TargetFrameworks>-->

<!--For UnitTesting the .NET Standard versions-->
<!--<TargetFrameworks>netcoreapp2.0;netcoreapp3.0</TargetFrameworks>-->
Expand Down Expand Up @@ -41,7 +41,34 @@
<!-- Project references -->
<ItemGroup>
<ProjectReference Include="..\KGySoft.Drawing.Core\KGySoft.Drawing.Core.csproj" />
<ProjectReference Include="..\Specific\GdiPlus\KGySoft.Drawing\KGySoft.Drawing.csproj" />
</ItemGroup>

<!-- .NET 7.0 or newer references: Unix is no nonger supported -->
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="System.Drawing.Common" Version="7.0.0-preview.4.22229.4" />
</ItemGroup>

<!-- .NET 5.0 or newer references: Unix is supported only by an app context switch (initialized by DrawingModule) -->
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

<!-- Legacy .NET Standard / .NET Core references (they cannot be upgraded, see https://github.com/dotnet/runtime/issues/59032) -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=_005Fextensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -303,30 +303,30 @@ private static void DoCommonCustomBitmapDataTests(string caseName, Size size, IR
AssertAreEqual(bitmapDataDitheredContentDependent, referenceBitmapData, true);

// DrawInto
using IReadableBitmapData icon32 = Icons.Information.ExtractBitmap(new Size(48, 48)).GetReadableBitmapData();
using IReadableBitmapData icon48 = GetInfoIcon48();
Point iconLocation = new Point(10, 10);
Rectangle gradientRectangle = new Rectangle(60, 10, 50, 42);

bitmapDataNonDithered.CopyTo(referenceBitmapData, default, referenceQuantizer);
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer);
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer);
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer);
icon32.DrawInto(bitmapDataNonDithered, iconLocation);
icon48.DrawInto(bitmapDataNonDithered, iconLocation);
alphaGradient.DrawInto(bitmapDataNonDithered, gradientRectangle);
SaveBitmapData($"{caseName} DrawInto", bitmapDataNonDithered, testName);
AssertAreEqual(referenceBitmapData, bitmapDataNonDithered, true);

bitmapDataDitheredContentIndependent.CopyTo(referenceBitmapData, default, referenceQuantizer);
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentIndependentDitherer);
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentIndependentDitherer);
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer, contentIndependentDitherer);
icon32.DrawInto(bitmapDataDitheredContentIndependent, iconLocation, contentIndependentDitherer);
icon48.DrawInto(bitmapDataDitheredContentIndependent, iconLocation, contentIndependentDitherer);
alphaGradient.DrawInto(bitmapDataDitheredContentIndependent, gradientRectangle, contentIndependentDitherer);
SaveBitmapData($"{caseName} DrawInto independent ditherer", bitmapDataDitheredContentIndependent, testName);
AssertAreEqual(referenceBitmapData, bitmapDataDitheredContentIndependent, true);

bitmapDataDitheredContentDependent.CopyTo(referenceBitmapData, default, referenceQuantizer);
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentDependentDitherer);
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentDependentDitherer);
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer, contentDependentDitherer);
icon32.DrawInto(bitmapDataDitheredContentDependent, iconLocation, contentDependentDitherer);
icon48.DrawInto(bitmapDataDitheredContentDependent, iconLocation, contentDependentDitherer);
alphaGradient.DrawInto(bitmapDataDitheredContentDependent, gradientRectangle, contentDependentDitherer);
SaveBitmapData($"{caseName} DrawInto dependent ditherer", bitmapDataDitheredContentDependent, testName);
//AssertAreEqual(referenceBitmapData, bitmapDataDitheredContentDependent, true); //- Due to serpentine processing the resizing draw can be different on 32bpp reference and actual bitmap data
Expand Down Expand Up @@ -476,9 +476,8 @@ public void SupportedFormatsConsistencyTest(KnownPixelFormat pixelFormat)
{
// 0.) Reference: native to self-allocating managed bitmap data
IReadWriteBitmapData reference;
using (Bitmap bmp = Icons.Information.ExtractBitmap(new Size(256, 256)))
using (var bmpData = GetInfoIcon256())
{
using var bmpData = bmp.GetReadWriteBitmapData();
int bpp = pixelFormat.ToBitsPerPixel();
reference = bmpData.Clone(pixelFormat, bpp <= 8 ? OptimizedPaletteQuantizer.Wu(1 << bpp, Color.Silver, (byte)(bpp == 1 ? 0 : 128)) : null, OrderedDitherer.Bayer8x8);
}
Expand Down Expand Up @@ -578,7 +577,7 @@ public void CustomIndexedBitmapDataTest(string testName, PixelFormatInfo pixelFo
int maxColors = 1 << bpp;
foreach (var getQuantizer in new Func<int, Color, byte, OptimizedPaletteQuantizer>[] { OptimizedPaletteQuantizer.Octree, OptimizedPaletteQuantizer.MedianCut, OptimizedPaletteQuantizer.Wu })
{
using IReadableBitmapData optimizedReferenceBitmapData = Icons.Information.ExtractBitmap(new Size(256, 256))!.GetReadableBitmapData()
using IReadableBitmapData optimizedReferenceBitmapData = GetInfoIcon256()
.Clone(bpp <= 8 ? KnownPixelFormat.Format8bppIndexed : KnownPixelFormat.Format32bppArgb, getQuantizer.Invoke(maxColors, Color.Silver, (byte)(bpp == 1 ? 0 : 128)), OrderedDitherer.Bayer8x8);
size = optimizedReferenceBitmapData.GetSize();
stride = pixelFormat.GetByteWidth(size.Width);
Expand Down
Loading

0 comments on commit 76b4cf9

Please sign in to comment.