Esempio n. 1
0
 /// <summary>
 /// Create an atlas texture element that contains all the information from the source texture.
 /// </summary>
 /// <param name="name">The reference name of the element</param>
 /// <param name="texture"></param>
 /// <param name="sourceRegion">The region of the element in the source texture</param>
 /// <param name="borderSize">The size of the border around the element in the output atlas</param>
 /// <param name="borderModeU">The border mode along the U axis</param>
 /// <param name="borderModeV">The border mode along the V axis</param>
 /// <param name="borderColor">The color of the border</param>
 public AtlasTextureElement(string name, Image texture, RotableRectangle sourceRegion, int borderSize, TextureAddressMode borderModeU, TextureAddressMode borderModeV, Color? borderColor = null)
 {
     Name = name;
     Texture = texture;
     SourceRegion = sourceRegion;
     BorderSize = borderSize;
     BorderModeU = borderModeU;
     BorderModeV = borderModeV;
     BorderColor = borderColor ?? Color.Transparent;
 }
Esempio n. 2
0
        // Note: this comparison function is not very robust and might have to be improved at some point (does not take in account RowPitch, etc...)
        private bool CompareImages(Image outputImage, Image referenceImage)
        {
            if (outputImage.Description != referenceImage.Description)
                return false;
            
            unsafe
            {
                var ptr1 = (Color*)outputImage.DataPointer;
                var ptr2 = (Color*)referenceImage.DataPointer;

                // Fill in mock data
                for (var i = 0; i < outputImage.Description.Height * outputImage.Description.Width; ++i)
                {
                    if (*ptr1 != *ptr2)
                        return false;

                    ++ptr1;
                    ++ptr2;
                }
            }

            return true;
        }
Esempio n. 3
0
        private void SaveAndCompareTexture(Image outputImage, string fileName, ImageFileType extension = ImageFileType.Png)
        {
            // save
            Directory.CreateDirectory(ImageOutputPath);
            outputImage.Save(new FileStream(ImageOutputPath + fileName + extension.ToFileExtension(), FileMode.Create), extension); 

            // Compare
            using(var texTool = new TextureTool())
            {
                var referenceImage = LoadImage(texTool, new UFile(GoldImagePath + "/" + fileName + extension.ToFileExtension()));
                Assert.IsTrue(CompareImages(outputImage, referenceImage), "The texture outputted differs from the gold image.");
            }
        }