C# Building an image from multiple images

Posted on 2006-05-24
Last Modified: 2006-11-18
I'm trying to taking multiple images and build them into one larger image.  The images seem to be getting enlarged when they are drawn into the single image.  I posted on google and someone suggested it might be the file types.
Please review the code and the link that points to the image and result I'm getting.

I'm still having issues.  I can get the images to add, but they are overlapping.  In this test example, I'm using one image, SlotLarge.jpg which is 48 x 67 pixels.
In the code below, you'll see that I add the first one at (0, 0) and the second one at (0, 68).  The second one is overlapping half of the first one.  I posted the original image and compiled image at

Here is the code and thanks again for your help:

        m_fileDir = @"c:\inetpub\wwwroot\pfs\images\machines\45countlarge\";

        m_Bitmap = new Bitmap(320, 600);
        Graphics g = Graphics.FromImage(m_Bitmap);

        System.Drawing.Image _img = System.Drawing.Image.FromFile(m_fileDir + "SlotLarge.jpg");
        g.DrawImage(_img, 0, 0);

        g.DrawImage(_img, 0, 68);

        m_Bitmap.Save(m_fileDir + "testimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Question by:spmcmorrow
    1 Comment
    LVL 6

    Accepted Solution


    Try replacing your g.DrawImage(_img, 0, 0); with g.DrawImage(_img, 0, 0, _img.Width, _img.Height);

    This should constrain the image to the right area.

    Let me know if it works


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    NotAlone Challenge 20 65
    scoresIncreasing challenge 10 47
    for loop with Set 4 36
    object oriented javascript web form 8 48
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now