There is a
Metafile class in the .NET framework that you can use to work with metafiles. Like
Bitmap, it derives from
Image, so much of the API is similar. Many of the methods of the
Graphics class work with Image rather than Bitmap, though, so you can use Bitmap and Metafile interchangeably with these methods. For example, here is an example of how you can resize the metafile and copy the resized metafile to the clipboard:
void CopyGraphToClipboard(AxCWGraph graph, int width, int height)
{
using (Image controlImage = graph.ControlImage())
using (Bitmap clipboardImage = new Bitmap(width, height))
using (Graphics g = Graphics.FromImage(clipboardImage))
{
g.DrawImage(controlImage, 0, 0, width, height);
Clipboard.SetDataObject(clipboardImage, true);
}
}
To copy an image of the graph to the clipboard whose width is 400 and height is 300, you can call this method like this:
CopyGraphToClipboard(axCWGraph, 400, 300);
Just out of curiosity, is there a reason that you're using the interop wrappers for the Measurement Studio ActiveX graph instead of using the native Measurement Studio .NET Windows Forms graph? The Measurement Studio .NET Windows Forms graph controls have a method called ToClipboard that will copy an image of the graph to the clipboard with the specified size. For example, the snippets above would look like this instead:
graph.ToClipboard(new Size(400, 300));
- Elton