tags:

views:

108

answers:

1

According to the msdn documentation:

GetPictureFromObject method Returns a picture (Visual Basic Picture object) of the current map view.

After digging around, I found that this "Picture" object apparently hasn't existed since VB6. I guess there's no way to write a class to masquerade as this type... Or is there?

A: 

It seems that this is a problem with no pretty solution.

public Image GetImage()
{
    Image image = null;
    object save = Clipboard.GetDataObject();
    try
    {
        Application.ActiveMap.CopyMap();
        IDataObject pict = Clipboard.GetDataObject();
        string[] formats = pict.GetFormats();
        foreach (string s in formats)
        {
            if (s.EndsWith(System.Windows.Forms.DataFormats.Bitmap))
            {
                image = (System.Drawing.Image)pict.GetData(System.Windows.Forms.DataFormats.Bitmap);
                break;
            }
        }
    }
    finally
    {
        Clipboard.SetDataObject(save);
    }
    return image;
}
Matt Jacobsen