Skip to content

Commit

Permalink
Releasing version v8.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koszeggy committed Dec 11, 2023
1 parent 848c729 commit e8a91ba
Show file tree
Hide file tree
Showing 28 changed files with 95 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand All @@ -11,7 +11,8 @@
<SingleProject>true</SingleProject>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>

<!--<SelfContained>true</SelfContained>-->

<!-- Display name -->
<ApplicationTitle>KGy SOFT Drawing SkiaSharp/MAUI Example</ApplicationTitle>

Expand Down Expand Up @@ -53,8 +54,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.3" />
<PackageReference Include="KGySoft.Drawing.SkiaSharp" Version="7.2.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.3" />
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.6" />
<PackageReference Include="KGySoft.Drawing.SkiaSharp" Version="8.0.0-rc.2" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions Examples/SkiaSharp_(Maui)/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ private async Task GenerateDisplayImage(Configuration cfg)
SKBitmap? result = null;
var asyncConfig = new TaskConfig { ThrowIfCanceled = false };

// ReSharper disable once MethodSupportsCancellation - ok but our token is not for this one (which is btw. default at this point)
// This is essentially a lock. Achieved by a SemaphoreSlim because an actual lock cannot be used with awaits in the code.
await syncRoot.WaitAsync();
try
Expand Down Expand Up @@ -309,11 +310,11 @@ private async Task GenerateDisplayImage(Configuration cfg)

// ===== b.) There is an image overlay: demonstrating how to work directly with IReadWriteBitmapData in SkiaSharp =====

// Creating the temp 32 bpp bitmap data to work with. Will be converted back to SKBitmap in the end.
// The Format32bppPArgb format is optimized for alpha blending in the sRGB color space but if linear working color space is selected
// it would just cause an unnecessary overhead. So for working in the linear color space we use a non-premultiplied format.
// Creating the temp bitmap data to work with. Will be converted back to SKBitmap in the end.
// The Format128bppPRgba format is optimized for alpha blending in the linear color space, whereas Format64bppPArgb in the sRGB color space.
// Any other format with enough colors would be alright, though.
using IReadWriteBitmapData resultBitmapData = BitmapDataFactory.CreateBitmapData(new System.Drawing.Size(baseImage.Width, baseImage.Height),
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format32bppArgb : KnownPixelFormat.Format32bppPArgb,
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format128bppPRgba : KnownPixelFormat.Format64bppPArgb,
workingColorSpace, cfg.BackColor, cfg.AlphaThreshold);

// b.1.) Drawing the source bitmap first. GetReadableBitmapData can be used for any SKBitmap with any actual pixel format.
Expand Down Expand Up @@ -359,7 +360,7 @@ private async Task GenerateDisplayImage(Configuration cfg)
result = displayResult;
}
}
// BUG WORKAROUND: SKBitmapImageSource handles SKBitmap incorrectly under a lot of conditions, which are also platform dependent
// BUG WORKAROUND: SKBitmapImageSource handles SKBitmap incorrectly under a lot of conditions, which are also platform dependent - https://github.com/mono/SkiaSharp/issues/2466
// - Everywhere, including Windows: only sRGB color space is displayed correctly so results with linear actual color space must be converted to sRGB
// - On Android: ColorType.Argb4444 is displayed incorrectly
// - On Mac/iOS: Everything but Rgba8888/Premul works incorrectly. Actually applying the workaround for all non-Windows/Android systems just for sure.
Expand Down
4 changes: 2 additions & 2 deletions Examples/WinForms/KGySoft.Drawing.Examples.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<OutputType>WinExe</OutputType>

<!--You can use the .NET Framework 4.7 build to execute the application on Linux/Mono-->
<TargetFrameworks>net6.0-windows;net47</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net47</TargetFrameworks>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KGySoft.Drawing" Version="7.2.0" />
<PackageReference Include="KGySoft.Drawing" Version="8.0.0-rc.2" />
</ItemGroup>

<Import Project="..\_Shared\KGySoft.Drawing.Examples.Shared.projitems" Label="Shared" />
Expand Down
8 changes: 4 additions & 4 deletions Examples/WinForms/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,11 @@ private async Task GenerateResult(Configuration cfg)

// ===== b.) There is an image overlay: demonstrating how to work directly with IReadWriteBitmapData in System.Drawing =====

// Creating the temp 32 bpp bitmap data to work with. Will be converted back to Bitmap in the end.
// The Format32bppPArgb format is optimized for alpha blending in the sRGB color space but if linear color space is selected
// it would just cause an unnecessary overhead. So for working in the linear color space we use a non-premultiplied format.
// Creating the temp bitmap data to work with. Will be converted back to Bitmap in the end.
// The Format128bppPRgba format is optimized for alpha blending in the linear color space, whereas Format64bppPArgb in the sRGB color space.
// Any other format with enough colors would be alright, though.
using IReadWriteBitmapData tempBitmapData = BitmapDataFactory.CreateBitmapData(new Size(cfg.Source!.Width, cfg.Source.Height),
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format32bppArgb : KnownPixelFormat.Format32bppPArgb,
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format128bppPRgba : KnownPixelFormat.Format64bppPArgb,
workingColorSpace, cfg.BackColor, cfg.AlphaThreshold);

// b.1.) Drawing the source bitmap first. GetReadableBitmapData can be used for any Bitmap with any actual pixel format.
Expand Down
4 changes: 2 additions & 2 deletions Examples/Wpf/KGySoft.Drawing.Examples.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows</TargetFrameworks>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KGySoft.Drawing.Wpf" Version="7.2.0" />
<PackageReference Include="KGySoft.Drawing.Wpf" Version="8.0.0-rc.1" />
</ItemGroup>

<Import Project="..\_Shared\KGySoft.Drawing.Examples.Shared.projitems" Label="Shared" />
Expand Down
8 changes: 4 additions & 4 deletions Examples/Wpf/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ private async Task GenerateResult(Configuration cfg)

// ===== b.) There is an image overlay: demonstrating how to work directly with IReadWriteBitmapData in WPF =====

// Creating the temp 32 bpp bitmap data to work with. Will be converted back to WriteableBitmap in the end.
// The Format32bppPArgb format is optimized for alpha blending in the sRGB color space but if linear color space is selected
// it would just cause an unnecessary overhead. So for working in the linear color space we use a non-premultiplied format.
// Creating the temp bitmap data to work with. Will be converted back to WriteableBitmap in the end.
// The Format128bppPRgba format is optimized for alpha blending in the linear color space, whereas Format64bppPArgb in the sRGB color space.
// Any other format with enough colors would be alright, though.
using IReadWriteBitmapData resultBitmapData = BitmapDataFactory.CreateBitmapData(new Size(cfg.Source!.PixelWidth, cfg.Source.PixelHeight),
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format32bppArgb : KnownPixelFormat.Format32bppPArgb,
workingColorSpace == WorkingColorSpace.Linear ? KnownPixelFormat.Format128bppPRgba: KnownPixelFormat.Format64bppPArgb,
workingColorSpace, cfg.BackColor.ToColor32(), cfg.AlphaThreshold);

// b.1.) Drawing the source bitmap first. GetReadableBitmapData can be used for any Bitmap with any actual pixel format.
Expand Down
2 changes: 1 addition & 1 deletion KGySoft.Drawing.Core/.nuspec/KGySoft.Drawing.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>KGySoft.Drawing.Core</id>
<version>8.0.0-rc.1</version>
<version>8.0.0</version>
<title>KGy SOFT Drawing Core Libraries</title>
<authors>György Kőszeg</authors>
<owners>György Kőszeg</owners>
Expand Down
2 changes: 1 addition & 1 deletion KGySoft.Drawing.Core/.nuspec/readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Thank you for installing KGy SOFT Drawing Core Libraries 8.0.0-rc.1
Thank you for installing KGy SOFT Drawing Core Libraries 8.0.0
KGy SOFT Drawing Core Libraries offer advanced drawing features for completely managed bitmap data on multiple platforms.

Release Notes: https://github.com/koszeggy/KGySoft.Drawing/blob/master/KGySoft.Drawing.Core/changelog.txt
Expand Down
4 changes: 2 additions & 2 deletions KGySoft.Drawing.Core/KGySoft.Drawing.Core.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;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp3.0;net5.0;net6.0;net8.0</TargetFrameworks>-->
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net35;net40;net45;net46;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp3.0;net5.0;net6.0;net8.0</TargetFrameworks>
<!--<TargetFrameworks>net8.0</TargetFrameworks>-->

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
Expand Down
2 changes: 1 addition & 1 deletion KGySoft.Drawing.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

[assembly: AssemblyVersion("8.0.0.0")]
[assembly: AssemblyFileVersion("8.0.0.0")]
[assembly: AssemblyInformationalVersion("8.0.0-rc.1")]
[assembly: AssemblyInformationalVersion("8.0.0")]

[assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("KGySoft.Drawing.Core.UnitTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001003928BADFAA8C02789566AB7AC64A59DCDE30B798589A68EF92CBB04C9DED3FCBFE41F644D424DCF82F8A13F9148D45EE15785450318388E01AA8C4CF645E81C772E39DCA0D14B33CF48167B70F5C34A0E7B763141ED3AFDDAD0373D9FCD2E153E78D201C5C4EB61DBBD586EC6291EABFBE11879865C3776088605FA8820387C2")]
Expand Down
2 changes: 1 addition & 1 deletion KGySoft.Drawing.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<DocumentationSource sourceFile="Specific\SkiaSharp\KGySoft.Drawing.SkiaSharp\KGySoft.Drawing.SkiaSharp.csproj" />
</DocumentationSources>
<HelpTitle>KGy SOFT Drawing Libraries Help</HelpTitle>
<HelpFileVersion>8.0.0-preview.1</HelpFileVersion>
<HelpFileVersion>8.0.0</HelpFileVersion>
<NamingMethod>MemberName</NamingMethod>
<ContentPlacement>AboveNamespaces</ContentPlacement>
<RootNamespaceContainer>False</RootNamespaceContainer>
Expand Down
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,25 +274,38 @@ bitmap.Unlock();
The previous example demonstrated how we can create a managed accessor for a `WriteableBitmap`. But it worked only because we used a pixel format that happens to have built-in support also in KGy SOFT Drawing Libraries. In fact, the libraries provide support for any custom pixel format. The [`CreateBitmapData`](https://docs.kgysoft.net/drawing/html/Overload_KGySoft_Drawing_Imaging_BitmapDataFactory_CreateBitmapData.htm) methods have several overloads that allow you to specify a custom pixel format along with a couple of delegates to be called when pixels are read or written:
```cs
// Gray8 format has no built-in support in KGySoft.Drawing.Core
// Though Gray8 format also has built-in support in KGySoft.Drawing.Core
// (see KnownPixelFormat.Format8bppGrayScale) here we pretend as if it was no supported natively.
// So this is our bitmap with the custom pixel format:
var bitmap = new WriteableBitmap(width, height, dpiX, dpiY, PixelFormats.Gray8, null);

// But we can specify how to use it
var customPixelFormat = new PixelFormatInfo { BitsPerPixel = 8, Grayscale = true };
Func<ICustomBitmapDataRow, int, Color32> getPixel =
(row, x) => Color32.FromGray(row.UnsafeGetRefAs<byte>(x));
Action<ICustomBitmapDataRow, int, Color32> setPixel =
(row, x, c) => row.UnsafeGetRefAs<byte>(x) = c.Blend(row.BitmapData.BackColor).GetBrightness();

// Now we specify also a dispose callback to be executed when the returned instance is disposed:
return BitmapDataFactory.CreateBitmapData(
bitmap.BackBuffer, new Size(bitmap.PixelWidth, bitmap.PixelHeight), bitmap.BackBufferStride,
customPixelFormat, getPixel, setPixel,
disposeCallback: () =>
// We need to specify a configuration that tells some info about the pixel format
// and how pixels can be got/set from known color formats.
var customConfig = new CustomBitmapDataConfig
{
PixelFormat = new PixelFormatInfo { BitsPerPixel = 8, Grayscale = true },
BackBufferIndependentPixelAccess = true,
BackColor = Color.Silver.ToColor32(), // black if not specified
// In this example we specify Color32 access but you can use other color types
// if they fit better for the format (eg. Color64, ColorF or their premultiplied counterparts).
// Note that the setter blends possible alpha colors with the back color.
RowGetColor32 = (row, x) => Color32.FromGray(row.UnsafeGetRefAs<byte>(x)),
RowSetColor32 = (row, x, c) => row.UnsafeGetRefAs<byte>(x) =
c.Blend(row.BitmapData.BackColor, row.BitmapData.WorkingColorSpace).GetBrightness(),

// Now we specify also a dispose callback to be executed when the returned instance is disposed:
DisposeCallback = () =>
{
bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
bitmap.Unlock();
});
}
};

// Returning an IReadWriteBitmapData instance that wraps our native bitmap with the custom format:
return BitmapDataFactory.CreateBitmapData(
bitmap.BackBuffer, new Size(bitmap.PixelWidth, bitmap.PixelHeight), bitmap.BackBufferStride,
customConfig);
```

> 💡 _Tip:_ See also the [Xamarin](Examples/Xamarin) and [MAUI](Examples/Maui) examples that demonstrate [how](https://github.com/koszeggy/KGySoft.Drawing/blob/8ac1a38317660a954ac6cf416c55d1fc3108c2fc/Examples/Maui/Extensions/SKBitmapExtensions.cs#L85) to create a bitmap data for SkiaSharp's `SKBitmap` type as if there was no dedicated package for SkiaSharp.
Expand Down
20 changes: 10 additions & 10 deletions Specific/GdiPlus/KGySoft.Drawing/.nuspec/KGySoft.Drawing.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>KGySoft.Drawing</id>
<version>8.0.0-rc.1</version>
<version>8.0.0</version>
<title>KGy SOFT Drawing Libraries</title>
<authors>György Kőszeg</authors>
<owners>György Kőszeg</owners>
Expand Down Expand Up @@ -43,36 +43,36 @@ SkiaSharp specific libraries: https://www.nuget.org/packages/KGySoft.Drawing.Ski
<repository type="git" url="https://github.com/koszeggy/KGySoft.Drawing" />
<dependencies>
<group targetFramework=".NETFramework3.5">
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
</group>
<group targetFramework=".NETFramework4.0">
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
</group>
<group targetFramework=".NETFramework4.6">
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
</group>
<group targetFramework="netcoreapp2.0" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="5.0.3" />
</group>
<group targetFramework="netcoreapp3.0" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="5.0.3" />
</group>
<group targetFramework="netstandard2.0" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="5.0.3" />
</group>
<group targetFramework="netstandard2.1" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="5.0.3" />
</group>
<group targetFramework="net5.0" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="6.0.0" />
</group>
<group targetFramework="net7.0" >
<dependency id="KGySoft.Drawing.Core" version="8.0.0-rc.1" />
<dependency id="KGySoft.Drawing.Core" version="8.0.0" />
<dependency id="System.Drawing.Common" version="8.0.0 " />
</group>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion Specific/GdiPlus/KGySoft.Drawing/.nuspec/readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Thank you for installing KGy SOFT Drawing Libraries 8.0.0-rc.1
Thank you for installing KGy SOFT Drawing Libraries 8.0.0
KGy SOFT Drawing Libraries offer advanced drawing features for System.Drawing types.

⚠️ Warning: Version 7.0.0 introduced several breaking changes. Most importantly, the technology-agnostic and
Expand Down
4 changes: 2 additions & 2 deletions Specific/GdiPlus/KGySoft.Drawing/KGySoft.Drawing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@

<!-- Release only package references -->
<ItemGroup Condition="'$(Configuration)' == 'RELEASE'">
<PackageReference Include="KGySoft.Drawing.Core" Version="8.0.0-rc.1" />
<PackageReference Include="KGySoft.Drawing.Core" Version="8.0.0" />
</ItemGroup>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

[assembly: AssemblyVersion("8.0.0.0")]
[assembly: AssemblyFileVersion("8.0.0.0")]
[assembly: AssemblyInformationalVersion("8.0.0-rc.1")]
[assembly: AssemblyInformationalVersion("8.0.0")]

[assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("KGySoft.Drawing.UnitTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001003928BADFAA8C02789566AB7AC64A59DCDE30B798589A68EF92CBB04C9DED3FCBFE41F644D424DCF82F8A13F9148D45EE15785450318388E01AA8C4CF645E81C772E39DCA0D14B33CF48167B70F5C34A0E7B763141ED3AFDDAD0373D9FCD2E153E78D201C5C4EB61DBBD586EC6291EABFBE11879865C3776088605FA8820387C2")]
Expand Down
Loading

0 comments on commit e8a91ba

Please sign in to comment.