friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2008-11-11 17:55:02

creamownedz
 active server protocol
creamownedz's display avatar
» FriendsterTalker
PsychoCoder
Class-S
Location: Ftalk & MCTF
Registered: 2008-03-22
Posts: 115
Last visit: Today
Reputation: 7

Merging 4 Images into 1 Image [C#]

Merging 4 Images into 1 Image.



Instructions:
Use:
//Merge 4 Images into 1
BackgroundImage = MergeImages(Image.FromFile(""), Image.FromFile(""), Image.FromFile(""), Image.FromFile(""));



Code:

        /// <summary>
        /// Merges 4 Images into 1 Image.
        /// </summary>
        /// <param name="image1">The Image you want in the Top-Left Corner.</param>
        /// <param name="image2">The Image you want in the Top-Right Corner.</param>
        /// <param name="image3">The Image you want in the Bottom-Left Corner.</param>
        /// <param name="image4">The Image you want in the Bottom-Right Corner.</param>
        /// <returns>An Image of 4</returns>
        public Image MergeImages(Image image1, Image image2, Image image3, Image image4)
        {
            //Get the Width of All the Images
            Int32 width = image1.Width + image2.Width + image3.Width + image4.Width;
            //Get the Height of All the Images
            Int32 height = image1.Height + image2.Height + image3.Height + image4.Height;
            //Create a new Bitmap with the Width and Height
            Bitmap bitmap = new Bitmap(width, height);

            //Get All of the x Pixels
            for (int w = 0; w < image1.Width; w++)
            {
                //Get All of the Y Pixels
                for (int h = 0; h < image1.Height; h++)
                {
                    //Create a new Bitmap from image1
                    Bitmap image = new Bitmap(image1);
                    //Set the Cooresponding Pixel
                    bitmap.SetPixel(w, h, image.GetPixel(w, h));
                }
            }
            //Get All of the x Pixels
            for (int w = 0; w < image2.Width; w++)
            {
                //Get All of the Y Pixels
                for (int h = 0; h < image2.Height; h++)
                {
                    //Create a new Bitmap from image2
                    Bitmap image = new Bitmap(image2);
                    //Set the Cooresponding Pixel
                    bitmap.SetPixel(image.Width + w, h, image.GetPixel(w, h));
                }
            }
            //Get All of the x Pixels
            for (int w = 0; w < image3.Width; w++)
            {
                //Get All of the Y Pixels
                for (int h = 0; h < image3.Height; h++)
                {
                    //Create a new Bitmap from image3
                    Bitmap image = new Bitmap(image3);
                    //Set the Cooresponding Pixel
                    bitmap.SetPixel(w, image.Height + h, image.GetPixel(w, h));
                }
            }
            //Get All of the x Pixels
            for (int w = 0; w < image4.Width; w++)
            {
                //Get All of the Y Pixels
                for (int h = 0; h < image4.Height; h++)
                {
                    //Create a new Bitmap from image4
                    Bitmap image = new Bitmap(image4);
                    //Set the Cooresponding Pixel
                    bitmap.SetPixel(image.Width + w, image.Height + h, image.GetPixel(w, h));
                }
            }
            
            //Return the new Bitmap
            return bitmap;
        }

...Giving of reputation are highly appreciating for me...
Computers don't make errors what they do they do on purpose
...computer is my expertise...
....an addicted coder....
....don't ripp all my tutorials....

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
Copyright © 2002–2009 PunBB

[ 11 queries - 3.294 second ]

Pay Per Click Ads by pay per click advertising by Kontera

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)