Пример #1
0
        private static Color[] GetColorAfterExport(Models models, int layer = 0)
        {
            ExportTest.Init(null);
            models.Export.Export(new ExportDescription(models.Pipelines[0].Image, ExportTest.ExportDir + "crop_test", "dds")
            {
                FileFormat = GliFormat.RGBA32_SFLOAT,
                Layer      = layer,
                Overlay    = models.Overlay.Overlay
            });
            var imported = IO.LoadImageTexture(ExportTest.ExportDir + "crop_test.dds");

            return(imported.GetPixelColors(LayerMipmapSlice.Mip0));
        }
Пример #2
0
        public void ExportOverlayed()
        {
            var models = new Models(1);

            models.AddImageFromFile(TestData.Directory + "sphere.png");
            models.Apply();
            // 31 by 31 image
            Assert.AreEqual(models.Images.Size.X, 31);
            Assert.AreEqual(models.Images.Size.Y, 31);

            var boxes = new BoxOverlay(models);

            models.Overlay.Overlays.Add(boxes);

            var dim = models.Images.Size;

            boxes.Boxes.Add(new BoxOverlay.Box
            {
                Start  = new Size2(18, 11).ToCoords(dim.XY),
                End    = new Size2(24, 20).ToCoords(dim.XY),
                Border = 1,
                Color  = new Color(1.0f, 1.0f, 0.0f)
            });

            boxes.Boxes.Add(new BoxOverlay.Box
            {
                Start  = new Size2(7, 9).ToCoords(dim.XY),
                End    = new Size2(15, 15).ToCoords(dim.XY),
                Border = 2,
                Color  = new Color(1.0f, 0.0f, 0.0f)
            });

            Assert.IsTrue(boxes.HasWork);
            Assert.IsNotNull(models.Overlay.Overlay);

            var filename = ExportTest.ExportDir + "overlayed";

            // create export directory
            ExportTest.Init(null);
            models.Export.Export(new ExportDescription(models.Pipelines[0].Image, filename, "png")
            {
                FileFormat = GliFormat.RGBA8_SRGB,
                Overlay    = models.Overlay.Overlay
            });

            var imported  = IO.LoadImageTexture(filename + ".png");
            var reference = IO.LoadImageTexture(TestData.Directory + "sphere_with_overlay.png");

            TestData.CompareColors(reference.GetPixelColors(LayerMipmapSlice.Mip0), imported.GetPixelColors(LayerMipmapSlice.Mip0), Color.Channel.Rgba, 0.0f);
        }