Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:07:31+00:00 2026-06-08T02:07:31+00:00

I have a list of same sized PNGs. I need to create a long

  • 0

I have a list of same sized PNGs. I need to create a long image, with all images next to each other. I have no progressed. 🙂

I have loaded all the image paths into a List<>, and then created a BitMap, with the height of the images, and the length of the number of images , multiplied by their widths. (All images are equal dimensions).

I then need to go through each image, and basically paste it into it’s correct position in my BitMap. Can anyone possibly help me with a routine to do this? Iterate through all my items – and paste them onto my Bitmap.

I have tried this, but it’s failing with: Generic GDI Error.

using(Bitmap newFiles = new Bitmap(outputFileWidth, outputFileHeight))
{
     using(Graphics graphics = Graphics.FromImage(newFiles))
     {
         graphics.DrawImage(
            testImage,
            new Rectangle(0, 0, originalWidth, originalHeight),
            new Rectangle(new Point(), testImage.Size),
            GraphicsUnit.Pixel);
     }
     newFiles.Save(@"c:\test.png");
}

I have not yet done the loops. I am just trying to add the first image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:07:33+00:00Added an answer on June 8, 2026 at 2:07 am

    Answer located! Error was due to a locked file. Actually, permission on my folders. And this is a fantastic routine that I hope helps someone else.

    public Bitmap Combine()
            {
                //read all images into memory
                List<Bitmap> images = new List<Bitmap>();
                Bitmap finalImage = null;
    
                try
                {
                    int width = 0;
                    int height = 0;
    
                    foreach (var image in files)
                    {
                        //create a Bitmap from the file and add it to the list
                        System.Drawing.Bitmap bitmap = new Bitmap(image.Filename);
    
                        //update the size of the final bitmap
                        width += bitmap.Width;
                        height = bitmap.Height > height ? bitmap.Height : height;
    
                        images.Add(bitmap);
                    }
    
                    //create a bitmap to hold the combined image
                    finalImage = new System.Drawing.Bitmap(width, height);
    
                    //get a graphics object from the image so we can draw on it
                    using (Graphics g = Graphics.FromImage(finalImage))
                    {
                        //set background color
                        g.Clear(Color.Black);
    
                        //go through each image and draw it on the final image
                        int offset = 0;
                        foreach (Bitmap image in images)
                        {
                            g.DrawImage(image,
                              new Rectangle(offset, 0, image.Width, image.Height));
                            offset += image.Width;
                        }
                    }
    
                    return finalImage;
                }
                catch (Exception ex)
                {
                    if (finalImage != null)
                        finalImage.Dispose();
    
                    throw ex;
                }
                finally
                {
                    //clean up memory
                    foreach (Bitmap image in images)
                    {
                        image.Dispose();
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of MovieClips layered on top of each other (the same
I have an IList<MyList> . I'd like with LINQ keep the same list (same
I have a list/collection of objects that may or may not have the same
The problem is: I have a list of objects, with some containing the same
I have an STL list of pointers, along with another pointer of the same
I have these three lists with the same number of elements List<String>competitoinsIDs = new
i have two collections of the same objects (same size list of course). items
What is the most efficient way to make all nested list items the same
I have an ArraysList containing M lists which are sorted. Each list in the
I have a list view that sometimes has long text. When the text is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.