MarkusPalcer / blurhash.net

The C#-Implementation of the Blurhash-Algorithm
MIT License
163 stars 13 forks source link

Net 5 - does not work at all. #19

Open incloudss opened 3 years ago

incloudss commented 3 years ago

Hi,

Library generates constant L~TSUA~q0000~q4S00~q~q000I~q hash. I am using belows piece of code to blurhash my images:

        var bitmap = new Bitmap(imagePath);

        var pixels = new Pixel[bitmap.Width,bitmap.Height];
        for (int i = 0;  i < bitmap.Width; i++)
        {
            for (int j = 0; j < bitmap.Height; j++)
            {
                var pixelColor = bitmap.GetPixel(i, j);
                pixels[i, j] = new Pixel(pixelColor.R, pixelColor.G, pixelColor.B);
            }
        }

        var blurhash = base.CoreEncode(pixels, 4, 3);
204504bySE commented 2 years ago

pixels[,] for CoreEncode() must have linear(0-1) RGB values, not 0-255 with sRGB gamma.

A sample is here. https://github.com/MarkusPalcer/blurhash.net/blob/master/Blurhash.ImageSharp/Encoder.cs

MarkusPalcer commented 2 years ago

Does the System.Drawing.Common.Blurhash package not work for you?

Because that's the already implemented version to blurhash an Image. The idea behind that is that the core contains the actual algorithm and based on that there are different libraries for different imaging libraries (like System.Drawing or ImageSharp)