-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ktos/Blurhash.SkiaSharp
- Loading branch information
Showing
5 changed files
with
141 additions
and
74 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Blurhash.Microsoft.Extensions.SkiaSharp/Blurhash.Microsoft.Extensions.SkiaSharp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageId>Blurhash.Microsoft.Extensions.SkiaSharp</PackageId> | ||
<Authors>Markus Palcer, Marcin Badurowicz</Authors> | ||
<NoWarn>$(NoWarn);CS1998</NoWarn> | ||
<Description>Bridge library to use Blurhash with SkiaSharp and ServiceExtensions</Description> | ||
<PackageVersion>2.0.0</PackageVersion> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageTags>blurhash;image encoding;skiasharp</PackageTags> | ||
<PackageProjectUrl>https://github.com/ktos/Blurhash.SkiaSharp</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<Copyright>Copyright © 2020-2022 Marcin Badurowicz, Markus Palcer</Copyright> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DocumentationFile>E:\Marcin\!Projekty\Blurhash.SkiaSharp\src\Blurhash.SkiaSharp.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Blurhash.Core" Version="2.0.0" /> | ||
<PackageReference Include="SkiaSharp" Version="2.88.0" /> | ||
<PackageReference Include="Blurhash.Microsoft.Extensions.Core" Version="2.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\Blurhash.SkiaSharp.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Blurhash.Microsoft.Extensions.Core; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using SkiaSharp; | ||
|
||
namespace Blurhash.Microsoft.Extensions.SkiaSharp | ||
{ | ||
/// <inheritdoc cref="Blurhash.Microsoft.Extensions.SkiaSharp.IBlurhasher" /> | ||
public class BlurhasherImpl : Blurhasher<SKBitmap>, IBlurhasher | ||
{ | ||
public BlurhasherImpl(IImageConverter<SKBitmap> imageConverter) : base(imageConverter) | ||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The blurhash algorithm abstraction for <see cref="SKBitmap"/> | ||
/// </summary> | ||
public interface IBlurhasher : IBlurhasher<SKBitmap> | ||
{ | ||
} | ||
|
||
public static class Extensions | ||
{ | ||
/// <summary> | ||
/// Adds the blurhash core and the converter for <see cref="SKBitmap"/> to the given <see cref="IServiceCollection"/><br /> | ||
/// Also enables you to request <see cref="IBlurhasher"/> | ||
/// </summary> | ||
public static IServiceCollection AddBlurhash(this IServiceCollection serviceCollection) | ||
{ | ||
return serviceCollection.AddBlurhashCore() | ||
.AddSingleton<IImageConverter<SKBitmap>, ImageConverter>() | ||
.AddSingleton<IBlurhasher, BlurhasherImpl>(); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public class ImageConverter : IImageConverter<SKBitmap> | ||
{ | ||
/// <inheritdoc /> | ||
public Pixel[,] ImageToPixels(SKBitmap image) => Blurhash.SkiaSharp.Blurhasher.ConvertBitmap(image); | ||
|
||
/// <inheritdoc /> | ||
public SKBitmap PixelsToImage(Pixel[,] pixels) => Blurhash.SkiaSharp.Blurhasher.ConvertToBitmap(pixels); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.