Exemple #1
0
        private bool TryPackRectangles(int testWidth, int testHeight, Dictionary <string, Rectangle> tempTargetRects)
        {
            ArevaloRectanglePacker rectanglePacker = new ArevaloRectanglePacker(testWidth, testHeight);

            foreach (var pair in _sourceRectangles)
            {
                Point placement;
                if (!rectanglePacker.TryPack(pair.Value.Width + padding, pair.Value.Height + padding, out placement))
                {
                    return(false);
                }

                // Add the destination rectangle to our dictionary
                tempTargetRects.Add(pair.Key, new Rectangle(placement.X, placement.Y, pair.Value.Width + padding, pair.Value.Height + padding));
            }
            return(true);
        }
Exemple #2
0
        private bool TestPackingImages(int testWidth, int testHeight, Dictionary <string, Rectangle> testImagePlacement)
        {
            // create the rectangle packer
            ArevaloRectanglePacker rectanglePacker = new ArevaloRectanglePacker(testWidth, testHeight);

            foreach (var image in files)
            {
                // get the bitmap for this file
                Size size = imageBitmaps[image].Size;

                // pack the image
                Point origin;
                if (!rectanglePacker.TryPack(size.Width + padding, size.Height + padding, out origin))
                {
                    return(false);
                }

                // add the destination rectangle to our dictionary
                testImagePlacement.Add(image, new Rectangle(origin.X, origin.Y, size.Width + padding, size.Height + padding));
            }

            return(true);
        }