Пример #1
0
        public void PackAndDrawHorizontalImageTest()
        {
            var target = new NonphotoIndexedAssemble_Accessor(new WebGreaseContext(new WebGreaseConfiguration()));
            var log    = new ImageMap_Accessor("ReplaceLog.xml");

            log.AppendPadding("0");
            target.ImageXmlMap = log;
            Bitmap actual = null;
            List <BitmapContainer_Accessor> data = null;

            try
            {
                data = GenerateData(WebGrease.ImageAssemble.ImageType_Accessor.NonphotoIndexed);
                Assert.IsTrue(data.Count > 0);
                actual = target.PackHorizontal(data, true, null);
                int totalWidth = data.Sum(bmp => bmp.Width);
                int maxHeight  = data.Max(bmp => bmp.Height);
                Assert.AreEqual(totalWidth, actual.Width);
                Assert.AreEqual(maxHeight, actual.Height);
            }
            finally
            {
                foreach (var entry in data)
                {
                    entry.Bitmap.Dispose();
                }

                if (actual != null)
                {
                    actual.Dispose();
                }
            }
        }
Пример #2
0
        public void AssembleTest_NonphotoIndexed()
        {
            var target = new NonphotoIndexedAssemble_Accessor(new WebGreaseContext(new WebGreaseConfiguration()))
            {
                PackingType = SpritePackingType_Accessor.Horizontal, AssembleFileName = "Combine.png", PaddingBetweenImages = 5
            };

            try
            {
                var log = new ImageMap_Accessor("ReplaceLog.xml");
                target.ImageXmlMap = log;
                var inputImages = GenerateData(WebGrease.ImageAssemble.ImageType_Accessor.NonphotoIndexed);
                target.Assemble(inputImages);
                log.SaveXmlMap();
                Assert.IsTrue(ValidateImageGenerationFromLog("ReplaceLog.xml"));
                ValidateLogFile(inputImages, target.AssembleFileName, target.PackingType);
            }
            finally
            {
                if (File.Exists(target.AssembleFileName))
                {
                    File.Delete(target.AssembleFileName);
                }
            }
        }
Пример #3
0
        public void OptimizeAndSaveTest_NonphotoIndexed()
        {
            Bitmap originalImage           = null;
            var    nonphotoIndexedAccessor = new NonphotoIndexedAssemble_Accessor(new WebGreaseContext(new WebGreaseConfiguration()));

            try
            {
                var log = new ImageMap_Accessor("ReplaceLog.xml");
                log.AppendPadding("0");
                nonphotoIndexedAccessor.ImageXmlMap      = log;
                nonphotoIndexedAccessor.AssembleFileName = "Combine.png";
                var gifData = GenerateData(ImageType_Accessor.NonphotoIndexed);
                originalImage = nonphotoIndexedAccessor.PackVertical(gifData, true, null);
                nonphotoIndexedAccessor.SaveImage(originalImage);
                Assert.IsTrue(File.Exists(nonphotoIndexedAccessor.AssembleFileName));
            }
            finally
            {
                if (originalImage != null)
                {
                    originalImage.Dispose();
                }
            }
        }
Пример #4
0
        public void PackAndDrawVerticalImageTest()
        {
            Bitmap actual = null;
            var    log    = new ImageMap_Accessor("ReplaceLog.xml");
            var    target = new NonphotoIndexedAssemble_Accessor(new WebGreaseContext(new WebGreaseConfiguration()))
            {
                AssembleFileName = "combine.png", ImageXmlMap = log
            };
            List <BitmapContainer_Accessor> data = null;

            try
            {
                data = GenerateData(ImageType_Accessor.NonphotoIndexed);
                Assert.IsTrue(data.Count > 0);
                actual = target.PackVertical(data, true, null);
                var maxWidth    = data.Max(bmp => bmp.Width);
                var totalHeight = data.Sum(bmp => bmp.Height);
                Assert.AreEqual(maxWidth, actual.Width);
                Assert.AreEqual(totalHeight, actual.Height);
            }
            finally
            {
                if (data != null)
                {
                    foreach (var entry in data)
                    {
                        entry.Bitmap.Dispose();
                    }
                }

                if (actual != null)
                {
                    actual.Dispose();
                }
            }
        }