concat two bitmaps?

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

is there anyway to connect to bitmaps together?
basically, I have a program that generates a graph as it runs, and I can
capture an image of the graph, but is there a way to take two captures, and
join them together so it looks like one big graph?
 
Well, what you would do is create a new image with dimensions big enough to
fit both of the smaller ones, create a Graphics objects from the destination
image, and then use the source objects to draw the source images on the
graphics from the destination image in the desired spots. Of course, all
this accomplishes is setting the two images next to each other; anything
requiring an actual change to the source images would be infinitely more
complicated to implement. Any questions?

Chris
 
I just noticed Christopher replied. But here's some code that should
do the trick:
(note, there's a lot of scaling, rotating, etc. you can do in the
gr.DrawImage).
Bitmap bmp1 = new Bitmap(@"C:\windows\Coffee Bean.bmp");
Bitmap bmp2 = new Bitmap(@"C:\windows\Soap Bubbles.bmp");
int width = bmp1.Width + bmp2.Width;
int height = Math.Max(bmp1.Height, bmp2.Height);
Bitmap fullBmp = new Bitmap(width, height);
Graphics gr = Graphics.FromImage(fullBmp);
gr.DrawImage (bmp1, 0, 0, bmp1.Width, bmp1.Height);
gr.DrawImage (bmp2, bmp1.Width, 0);
fullBmp.Save( blah );
 
Back
Top