Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i merge multiple images into a single image ?

Tags:

c#

bitmap

I have an array of Images all of the same size . I should add them to a new image like i have shown in the picture.

Different colors represent different images. enter image description here

like image 937
Sanu Uthaiah Bollera Avatar asked Oct 20 '25 10:10

Sanu Uthaiah Bollera


1 Answers

  1. Identify the size of final image
  2. Create a bitmap with final height and width var bitmap = new Bitmap(width, height);
  3. Draw each image on canvas

    using (var canvas = Graphics.FromImage(bitmap))
    {
        canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
        //Draw each image (maybe use a loop to loop over images to draw)
            canvas.DrawImage(someImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, Frame.Width, Frame.Height), GraphicsUnit.Pixel);
    
        canvas.Save();
    }
    
  4. Save the final image bitmap.Save("image path", ImageFormat.Jpeg);
like image 120
Mayank Avatar answered Oct 21 '25 22:10

Mayank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!