[Last Call] Learn how to a build a cloud-first strategyRegister Now


C# Building an image from multiple images

Posted on 2006-05-24
Medium Priority
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 http://www.byrd48.net/imagetest.htm

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

Accepted Solution

neilprice earned 2000 total points
ID: 16755176

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


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

834 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