Image Stitching Test

Source: Internet
Author: User

Add Image function

        Private Image Joinimage (list<image> imageList, Joinmode JM) {//Picture List            if (imagelist.count <= 0) return null;                if (JM = = joinmode.horizontal) {//cross stitch int width = 0;                Calculates the total length of the foreach (Image i in imageList) {width + = i.width;                }//height constant int height = Imagelist.max (x = x.height);                Construct the final picture whiteboard Bitmap tablechartimage = new Bitmap (width, height);                Graphics graph = graphics.fromimage (tablechartimage); Initialize this large graph of graph.                DrawImage (tablechartimage, width, height);                Initializes the current wide int currentwidth = 0; foreach (Image i in imageList) {//Puzzle graph.                    DrawImage (i, currentwidth, 0);   After stitching the image, the current width                 Currentwidth + = I.width;            } return tablechartimage;                } else if (JM = = joinmode.vertical) {//Vertical stitching int height = 0;                Calculates the total length of the foreach (Image i in imageList) {height + = i.height;                }//Width invariant int width = Imagelist.max (x = x.width);                Construct the final picture whiteboard Bitmap tablechartimage = new Bitmap (width, height);                Graphics graph = graphics.fromimage (tablechartimage); Initialize this large graph of graph.                DrawImage (tablechartimage, width, height);                Initializes the current wide int currentheight = 0; foreach (Image i in imageList) {//Puzzle graph.                    DrawImage (i, 0, currentheight);                After stitching the image, the current width currentheight + = i.height;   }             return tablechartimage;            } else {return null; }        }

Stitching test (under button event)

            Bitmap Image1 = new Bitmap (application.startuppath + "\ \ Untitled -2_01.bmp");            Bitmap Image2 = new Bitmap (application.startuppath + "\ \ Untitled -2_02.bmp");            Picturebox2.image = Image1;            Picturebox3.image = Image2;            System.Windows.Forms.PictureBox AA = new PictureBox (); Aa.            Image = Image1; Image Img1=aa.            Image; Aa.            Image = Image2; Image img2 = aa.            Image; int unitewidth = IMG1. width;//picture uniform height int uniteheight = img1. height;//Picture Uniform width Bitmap tableChartImageCol1 = new Bitmap (Unitewidth * 2, uniteheight);//First line picture list&lt            ;image> imageList = new list<image> ();            list<image> imglistcopy = new list<image> ();            Imagelist.add (IMG1);            Imagelist.add (IMG2); foreach (Image i in imageList)//Stupid method, re-new picture, change picture height width {Bitmap b = new Bitmap (i, Unitewidth, unit                Eheight); Imglistcopy.add (b);                    } for (int i = 0; i < 2; i++) {if (imagelist.count-1 >= i) { Imagelist[i] = imglistcopy[i];//changed picture, assigned to original picture} if (true)//go into puzzle/                /Horizontal Stitching {//Picture whiteboard 1 Graphics graph = graphics.fromimage (tableChartImageCol1); Initialize this large graph of graph.                DrawImage (TableChartImageCol1, Unitewidth * 2, uniteheight);                Initializes the current wide int currentwidth = 0; Graph.  Clear (System.Drawing.Color.White); Clears the canvas with the background set to white foreach (Image i in imageList) {graph. DrawImage (i, currentwidth, 0);//puzzle--the picture is spelled up currentwidth + = I.width; After stitching the image, the current width} picturebox1.image = tableChartImageCol1;

One, to be stitching pictures

Stitching Complete effect

Image Stitching Test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.