public void CanEncodeBitmap(string source, int compX, int compY, string expected)
        {
            using var img = SKBitmap.Decode(Path.Combine("images", source));

            var result = SKBlurHash.Serialize(img, compX, compY);

            Assert.Equal(expected, result);
        }
        public void DecodeImageEqualsBitmap(string encoded)
        {
            var bmp = SKBlurHash.DeserializeBitmap(encoded, 20, 10);
            var img = SKBlurHash.DeserializeImage(encoded, 20, 10);

            Assert.Equal(
                bmp.PeekPixels().GetPixelSpan().ToArray(),
                img.PeekPixels().GetPixelSpan().ToArray());
        }
        public void CanEncodeAndDecode()
        {
            using var img = SKBitmap.Decode(Path.Combine("images", "img1.jpg"));

            var encoded = SKBlurHash.Serialize(img, 4, 3);

            Assert.NotNull(encoded);
            Assert.True(encoded.Length > 6);

            var decoded = SKBlurHash.DeserializeBitmap(encoded, 12, 10);

            Assert.NotNull(decoded);
        }
 public void NullEncodeThrows()
 {
     Assert.Throws <ArgumentNullException>(() => SKBlurHash.Serialize((SKBitmap)null, 4, 3));
 }
 public void NullDecodeThrows()
 {
     Assert.Throws <ArgumentNullException>(() => SKBlurHash.DeserializeImage(null, 20, 10));
 }
        public void DecodeImage(string encoded)
        {
            var img = SKBlurHash.DeserializeImage(encoded, 20, 10);

            Assert.NotNull(img);
        }
        public void DecodeBitmap(string encoded)
        {
            var bmp = SKBlurHash.DeserializeBitmap(encoded, 20, 10);

            Assert.NotNull(bmp);
        }
 public void InvalidDataThrows(string encoded)
 {
     Assert.Throws <ArgumentException>(() => SKBlurHash.DeserializeBitmap(encoded, 20, 10));
 }