
Merging 4 Images into 1 Image.
Instructions:
Use:
//Merge 4 Images into 1
BackgroundImage = MergeImages(Image.FromFile(""), Image.FromFile(""), Image.FromFile(""), Image.FromFile(""));
/// <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;
}-Offline- |