コード例 #1
0
 /// <summary>
 /// Add an image to the end of the pages. This is a good function to use
 /// if all the images are the same size, since it will only add images
 /// to the last page. This will result in worse packing (if the images
 /// are different sizes), but allows images to be added to the atlas
 /// quicker.
 /// </summary>
 /// <param name="name">The name of the image.</param>
 /// <param name="image">A bitmap of the image.</param>
 /// <returns>The page the image was added to.</returns>
 public ImageAtlasPage addImageToEnd(String name, FreeImageBitmap image)
 {
     checkImageDimensions(image);
     if (lastPage == null)
     {
         lastPage = new ImageAtlasPage(String.Format("{0}_Page{1}", this.name, allPages.Count), groupName, pageWidth, pageHeight);
         allPages.Add(lastPage);
     }
     if (!lastPage.addImage(name, image))
     {
         lastPage = null;
         return(addImageToEnd(name, image));
     }
     return(lastPage);
 }
コード例 #2
0
        /// <summary>
        /// Add an image. This will attempt to put the image on whatever page it
        /// can fit on. This will produce better packing for different sized
        /// images, but will slow down as pages are added, since it has to try
        /// to add to them all.
        /// </summary>
        /// <param name="name">The name of the image</param>
        /// <param name="image">The image</param>
        /// <returns>The page the image was added to.</returns>
        public ImageAtlasPage addImage(String name, FreeImageBitmap image)
        {
            checkImageDimensions(image);
            foreach (ImageAtlasPage page in allPages)
            {
                if (page.addImage(name, image))
                {
                    return(page);
                }
            }
            ImageAtlasPage newPage = new ImageAtlasPage(String.Format("{0}_Page{1}", this.name, allPages.Count), groupName, pageWidth, pageHeight);

            newPage.addImage(name, image);
            allPages.Add(newPage);
            return(newPage);
        }