Insert smaller images into one Image object

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have a windows forms project done in vb.net. One of the forms
creates graphs based on the data supplied to it. I want to take
multiple graphs and paste them into a larger Image object. I already
have the code to create a single graph. I'm hoping that I can take
these graphs and paste them into a given spot in the larger image.
I've heard of bitblt and stretchblt but I'm not certain if those
functions are out of date with the ,net framework. What is the best
way to solve this problem?

Brian
 
Brian said:
I have a windows forms project done in vb.net. One of the forms
creates graphs based on the data supplied to it. I want to take
multiple graphs and paste them into a larger Image object. I
already have the code to create a single graph. I'm hoping that I
can take these graphs and paste them into a given spot in the larger
image. I've heard of bitblt and stretchblt but I'm not certain if
those functions are out of date with the ,net framework. What is
the best way to solve this problem?

Use the large image's CreateGraphics method and paint on the returned
Graphics object using DrawImage. When done, don't forget to Dispose the
graphics object. (VB2005: "Using" keyword is available)


Armin
 
Use the large image's CreateGraphics method and paint on the returned
Graphics object using DrawImage. When done, don't forget to Dispose the
graphics object. (VB2005: "Using" keyword is available)

Armin

Is there a way to take my already created smaller graphics objects
(graphs) and insert them into the larger graphics object or are you
saying that I should draw the smaller graphs in the confines of the
larger object using the normal graphics drawing functions?

Also to dispose of a graphics object properly do I just use
the .dispose() function of the graphics object?

Brian
 
Brian said:
Is there a way to take my already created smaller graphics objects
(graphs) and insert them into the larger graphics object or are you
saying that I should draw the smaller graphs in the confines of the
larger object using the normal graphics drawing functions?

A Graphics objects is used to draw on a drawing surface. The drawing
surface can be something like the screen or a Bitmap object.

In this case you will be creating a Graphics object to draw on the
larger Bitmap. Use the Graphics.FromImage method to do that. You use the
DrawImage method to draw the smaller Bitmaps onto the larger Bitmap.
Also to dispose of a graphics object properly do I just use
the .dispose() function of the graphics object?

Yes.

Alternatively, in VB 2005 you can use the Using keyword. That will wrap
the code in a Try...Finally block and call the Dispose method in the
Finally part, so that the object is always properly disposed no matter
what happens.
 
Back
Top