Git Product home page Git Product logo

blurhash.uwp's Introduction

Blurhash.UWP

NuGet

A Blurhash implementation based on blurhash.net for Universal Windows Platform's native SoftwareBitmap.

Allows to encode a SoftwareBitmap into a blurhash and decode a blurhash into SoftwareBitmap again. Several portions of the code are directly copy-pasted from the System.Drawing implementation.

Available for x86, x64, ARM and ARM64. Requires .NET Standard 1.6 support, thus Windows 10 16299 (Fall Creators Update) or later is required.

Example usage

Displaying a placeholder for an image in Image control

using Blurhash.UWP;

// ...

var bitmap = Blurhasher.Decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 269, 173);

var source = new SoftwareBitmapSource();
await source.SetBitmapAsync(bitmap);

// Set the source of the Image control
image1.Source = source;

Calculating the blurhash for an image loaded from file

var fileOpenPicker = new FileOpenPicker();
fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
fileOpenPicker.FileTypeFilter.Add(".jpg");
fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;

var inputFile = await fileOpenPicker.PickSingleFileAsync();

if (inputFile == null)
{
    return;
}
else
{
    SoftwareBitmap softwareBitmap;

    using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read))
    {
        var decoder = await BitmapDecoder.CreateAsync(stream);

        softwareBitmap = await decoder.GetSoftwareBitmapAsync();
        
        var blurhash = Blurhasher.Encode(softwareBitmap, 4, 3);
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.