Blurhash.Microsoft.Extensions.SkiaSharp 2.0.0

.NET Standard 2.0
dotnet add package Blurhash.Microsoft.Extensions.SkiaSharp --version 2.0.0
NuGet\Install-Package Blurhash.Microsoft.Extensions.SkiaSharp -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blurhash.Microsoft.Extensions.SkiaSharp" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blurhash.Microsoft.Extensions.SkiaSharp --version 2.0.0
#r "nuget: Blurhash.Microsoft.Extensions.SkiaSharp, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Blurhash.Microsoft.Extensions.SkiaSharp as a Cake Addin
#addin nuget:?package=Blurhash.Microsoft.Extensions.SkiaSharp&version=2.0.0

// Install Blurhash.Microsoft.Extensions.SkiaSharp as a Cake Tool
#tool nuget:?package=Blurhash.Microsoft.Extensions.SkiaSharp&version=2.0.0

Blurhash.SkiaSharp

NuGet

Build Status

A Blurhash implementation based on blurhash.net for SkiaSharp, thus fully available for Xamarin and other .NET Standard 2.0 platforms.

Currently allows to decode a blurhash into SKBitmap or encode a SKBitmap into Blurhash string.

Several portions of the code are directly copy-pasted from the System.Drawing implementation.

Tested on Xamarin.Forms on UWP, iOS and Android.

Example usage

Displaying a placeholder for an image in Xamarin.Forms Image control

// decode blurhash instring into a SKBitmap
var im = Blurhash.SkiaSharp.Blurhasher.Decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 219, 176);

// load it into a SKImage
var data = SKImage.FromBitmap(im).Encode();

// use as a source for Image control
image1.Source = ImageSource.FromStream(data.AsStream);

Encoding an resource image into a Blurhash string

// get the image from resources
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TestMobileApp.noah.jpg");

// load to SKImage and to Image control
var img = SKImage.FromEncodedData(stream);
image1.Source = ImageSource.FromFile("noah.jpg");

// create SKBitmap from Image and create a blurhash for it
var hash = Blurhash.SkiaSharp.Blurhasher.Encode(SKBitmap.FromImage(img), 4, 3);

// and show it in a Editor control
editor1.Text = hash;

Example of Xamarin.Forms image with Blurhash switching to loaded image

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 126 5/24/2022