Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="image1"></param>
        /// <param name="image2"></param>
        /// <param name="alignment"></param>
        /// <returns></returns>
        public static Image ConcatImage(Image image1, Image image2, ImageConcatType alignment)
        {
            Bitmap imageBk = null;
            switch(alignment)
            {
                case ImageConcatType.Horizontal:
                    imageBk = new Bitmap(image1.Width + image2.Width, Math.Max(image1.Height, image2.Height));
                    break;
                case ImageConcatType.Vertical:
                    imageBk = new Bitmap(Math.Max(image1.Width, image2.Width), image1.Height + image2.Height);
                    break;
            }

            Graphics g = Graphics.FromImage(imageBk);
            switch (alignment)
            {
                case ImageConcatType.Horizontal:
                    g.DrawImage(image1, 0, 0);
                    g.DrawImage(image2, image1.Width, 0);
                    break;
                case ImageConcatType.Vertical:
                    g.DrawImage(image1, 0, 0);
                    g.DrawImage(image2, 0, image1.Height);
                    break;
            }
            return imageBk;
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image1"></param>
        /// <param name="image2"></param>
        /// <param name="alignment"></param>
        /// <returns></returns>
        public static Image ConcatImage(Image image1, Image image2, ImageConcatType alignment)
        {
            Bitmap imageBk = null;

            switch (alignment)
            {
            case ImageConcatType.Horizontal:
                imageBk = new Bitmap(image1.Width + image2.Width, Math.Max(image1.Height, image2.Height));
                break;

            case ImageConcatType.Vertical:
                imageBk = new Bitmap(Math.Max(image1.Width, image2.Width), image1.Height + image2.Height);
                break;
            }

            Graphics g = Graphics.FromImage(imageBk);

            switch (alignment)
            {
            case ImageConcatType.Horizontal:
                g.DrawImage(image1, 0, 0);
                g.DrawImage(image2, image1.Width, 0);
                break;

            case ImageConcatType.Vertical:
                g.DrawImage(image1, 0, 0);
                g.DrawImage(image2, 0, image1.Height);
                break;
            }
            return(imageBk);
        }