Beispiel #1
0
        public void PickColorTest()
        {
            var pixelCoordinate1  = new Int2(4, 4);
            var theoreticalColor1 = new Color(0, 255, 46, 255);
            var pixelCoordinate2  = new Int2(3, 4);
            var theoreticalColor2 = new Color(222, 76, 255, 255);

            var images = new[] { "BgraSheet.dds", "RgbaSheet.dds" };

            foreach (var image in images)
            {
                using (var texTool = new TextureTool())
                    using (var texImage = texTool.Load(Module.PathToInputImages + image))
                    {
                        var foundColor = texTool.PickColor(texImage, pixelCoordinate1);
                        Assert.Equal(theoreticalColor1, foundColor);

                        foundColor = texTool.PickColor(texImage, pixelCoordinate2);
                        Assert.Equal(theoreticalColor2, foundColor);
                    }
            }
        }
Beispiel #2
0
        public Color?PickPixelColor(UFile source, Vector2 initialPoint)
        {
            var image = cache.FirstOrDefault(x => x.Item1 == source)?.Item3;

            if (image == null)
            {
                return(null);
            }

            var pixelPoint = new Int2((int)initialPoint.X, (int)initialPoint.Y);

            using (var texTool = new TextureTool())
            {
                return(texTool.PickColor(image, pixelPoint));
            }
        }
Beispiel #3
0
        public void PickColorTest()
        {
            var pixelCoordinate1 = new Int2(4, 4);
            var theoreticalColor1 = new Color(0, 255, 46, 255);
            var pixelCoordinate2 = new Int2(3, 4);
            var theoreticalColor2 = new Color(222, 76, 255, 255);

            var images = new[] { "BgraSheet.dds", "RgbaSheet.dds" };

            foreach (var image in images)
            {
                using (var texTool = new TextureTool())
                using (var texImage = texTool.Load(Module.PathToInputImages + image))
                {
                    var foundColor = texTool.PickColor(texImage, pixelCoordinate1);
                    Assert.AreEqual(theoreticalColor1, foundColor);

                    foundColor = texTool.PickColor(texImage, pixelCoordinate2);
                    Assert.AreEqual(theoreticalColor2, foundColor);
                }
            }
        }