コード例 #1
0
        public void LinearTosRGB_RoundTrip_Success(float value)
        {
            int i         = CoreBlurHashEncoder.LinearTosRGB(value);
            var roundtrip = CoreBlurHashEncoder._sRGBToLinearLookup[i];

            Assert.Equal(value, roundtrip, 9);
        }
コード例 #2
0
        internal static unsafe string EncodeInternal(int xComponent, int yComponent, Bitmap bitmap, PixelFormat pixelFormat)
        {
            var width  = bitmap.Width;
            var height = bitmap.Height;

            // Lock the bitmap's bits.
            var bmpData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);

            // Get the address of the first line.
            var ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            var bytes = Math.Abs(bmpData.Stride) * height;

            var hash = CoreBlurHashEncoder.Encode(xComponent, yComponent, width, height, new ReadOnlySpan <byte>(ptr.ToPointer(), bytes), bmpData.Stride, pixelFormat);

            bitmap.UnlockBits(bmpData);
            return(hash);
        }
コード例 #3
0
 public float MaxFAvx() => CoreBlurHashEncoder.MaxFAvx(_data);
コード例 #4
0
 internal static string EncodeInternal(int xComponent, int yComponent, SKBitmap bitmap)
 => CoreBlurHashEncoder.Encode(xComponent, yComponent, bitmap.Width, bitmap.Height, bitmap.GetPixelSpan(), bitmap.RowBytes, PixelFormat.RGB888x);
コード例 #5
0
 public void SignSqrtF_Success(float value, float excpected)
 {
     Assert.Equal(excpected, CoreBlurHashEncoder.SignSqrtF(value), 9);
 }