Uchiha Itachi
Uchiha Itachi

Reputation: 1271

Append a Bitmap?

Is it possible to append a Bitmap file. By this I mean:

Is it possible to load in my initial image, then continue to load in new images, but place them at the bottom of the previous image (maybe with a break of like 20 pixels)?

I've never seen anything like this done before, so if anyone has any experience in doing so, it would be a huge help!!

Upvotes: 0

Views: 1880

Answers (1)

Abion47
Abion47

Reputation: 24671

This should do the trick.

public Bitmap AppendBitmap(Bitmap source, Bitmap target, int spacing)
{
    int w = Math.Max(source.Width, target.Width);
    int h = source.Height + target.Height + spacing;
    Bitmap bmp = new Bitmap(w, h);

    using (Graphics g = Graphics.FromImage(bmp))
    {
        g.DrawImage(source, 0, 0);
        g.DrawImage(target, 0, source.Height + spacing);
    }

    return bmp;
}

Upvotes: 2

Related Questions