Example #1
0
        public void CreateMaskTree_should_work()
        {
            var memoryStream = GeneratePngStream();
            var argbBytes    = PngToArgb.Convert(memoryStream, out _, out _);
            var alpha32Bytes = ExtractAlpha.ArgbToAlpha32(argbBytes);
            var maskTree     = MaskTree.Make(alpha32Bytes, Width, Height);

            Assert.IsTrue(maskTree == 0b11111110);

            memoryStream.Dispose();
        }
Example #2
0
        public unsafe void ConvertPngToRgba_should_work()
        {
            var memoryStream = GeneratePngStream();
            var argbBytes    = PngToArgb.Convert(memoryStream, out var width, out var height);

            Assert.AreEqual(argbBytes.Length, width * height * 4);

            var argbUints = argbBytes.ToUintPtr();

            Assert.IsTrue(argbUints[0] == 0xFF000000);
            Assert.IsTrue(argbUints[1] == 0x00FF0000);
            Assert.IsTrue(argbUints[2] == 0x0000FF00);
            Assert.IsTrue(argbUints[3] == 0x000000FF);
            Assert.IsTrue(argbUints[4 + Width] == 0xFFFFFFFF);
            Assert.IsTrue(argbUints[5 + Width] == 0xFF0000FF);
            Assert.IsTrue(argbUints[6 + Width] == 0xFFFF00FF);
            Assert.IsTrue(argbUints[7 + Width] == 0x00000000);

            memoryStream.Dispose();
        }
Example #3
0
        public unsafe void ExtractAlpha_should_work()
        {
            var memoryStream = GeneratePngStream();
            var argbBytes    = PngToArgb.Convert(memoryStream, out _, out _);

            var alpha32Bytes = ExtractAlpha.ArgbToAlpha32(argbBytes);

            var argbUints = alpha32Bytes.ToUintPtr();

            Assert.IsTrue(argbUints[0] == 0xFFFFFFFF);
            Assert.IsTrue(argbUints[1] == 0x00000000);
            Assert.IsTrue(argbUints[2] == 0x00000000);
            Assert.IsTrue(argbUints[3] == 0x00000000);

            Assert.IsTrue(argbUints[4 + Width] == 0xFFFFFFFF);
            Assert.IsTrue(argbUints[5 + Width] == 0xFFFFFFFF);
            Assert.IsTrue(argbUints[6 + Width] == 0xFFFFFFFF);
            Assert.IsTrue(argbUints[7 + Width] == 0x00000000);

            memoryStream.Dispose();
        }