CadEditor.UtilsGDI.GlueImages C# (CSharp) Метод

GlueImages() публичный статический Метод

public static GlueImages ( Image images, int width, int height ) : Bitmap
images Image
width int
height int
Результат System.Drawing.Bitmap
        public static Bitmap GlueImages(Image[] images, int width, int height)
        {
            int totalImageWidth = 0;
            int totalImageHeight = 0;
            for (int x = 0; x < width; x++)
            {
                totalImageWidth += images[x].Width;
            }
            for (int y = 0; y < height; y++)
            {
                totalImageHeight += images[y * width].Height;
            }

            var totalImage = new Bitmap(totalImageWidth, totalImageHeight);
            using (var g = Graphics.FromImage(totalImage))
            {
                int currentY = 0;
                for (int y = 0; y < height; y++)
                {
                    int currentX = 0;
                    int currentMaxY = 0;
                    for (int x = 0; x < width; x++)
                    {
                        var im = images[y * width + x];
                        g.DrawImage(im, new Point(currentX, currentY));
                        currentX += im.Width;
                        currentMaxY = Math.Max(currentMaxY, im.Height);
                        if (x == width-1)
                        {
                            currentY += currentMaxY;
                        }
                    }
                }
            }
            return totalImage;
        }

Usage Example

Пример #1
0
        private void exportPictures(string filename)
        {
            //bigBlocksImages = ConfigScript.videoNes.makeBigBlocks(curVideo, curTileset, bigBlockIndexes, curPallete, curViewType, 1, 2.0f, MapViewType.Tiles, false, curHierarchyLevel);
            var result = UtilsGDI.GlueImages(bigBlocksImages, bigBlocksImages.Length, 1);

            result.Save(filename);
        }