How to make images of components

Here is the example code in C Sharp and VB:

This example shows how you can make an image of interesting data with PCB-Investigator. If you want to save the visible area there is a very simple method in IPCBIWindow:

//for current view you can use this example:
Bitmap curView = mainWindowPCBI.GetCurrentPicture();
curView.Save(@"C:\E\tests\curView.png", System.Drawing.Imaging.ImageFormat.Png);

Otherwise you can use the step to create an image of a layer list and a defined area:

IPCBIWindow mainWindowPCBI; //fill e.g. in load or on other button click with mainWindowPCBI = IAutomation.CreateNewPCBIWindow(true);
    private void buttonExportImage_Click(object sender, EventArgs e)
      IStep step = mainWindowPCBI.GetCurrentStep();
      if (step == null) return;
      ICMPLayer layerCMPsTop = step.GetCMPLayer(true);
      //exisits the compnenent layer?
      if (layerCMPsTop == null) return;
      List<IObject> layerObjectList = layerCMPsTop.GetAllLayerObjects();
      //is there a compnent on the layer?
      if (layerObjectList.Count == 0) return;
      //for the example we use the first component, you can search for each component attribut you want
      SaveImageFromComponent((ICMPObject)layerObjectList[0], step, @"C:\E\tests\");
      //something went wrong?
      string errorLog = IAutomation.GetErrorLog();
    /// <summary>
    /// This example shows how to make an image of an component with connections on the signal layer below.
    /// </summary>
    /// <param name="CMPforImage">The relevant component</param>
    /// <param name="step">current step from the component</param>
    /// <param name="FileLocation">Where should we save the image?</param>
    public void SaveImageFromComponent(ICMPObject CMPforImage, IStep step, string FileLocation)
      List<ILayer> layers = new List<ILayer>(); //for the image we need all layers who are visible
      ICMPLayer CMPlayer = step.GetCMPLayer(CMPforImage.PlacedTop);
      IODBLayer outsideSignalLayer = step.GetOutsideODBLayer(CMPforImage.PlacedTop);
      if (CMPlayer == null) return; //check the layer is existing? maybe wrong job?
      if (outsideSignalLayer != null) //we want to see where are pins connected
      RectangleF boundsRelevantCMP = CMPforImage.GetBounds();
      boundsRelevantCMP.Inflate(100, 100); //show a little bit of the area around the component
      //create the image and save it as png
      PCBI.Automation.IStep.BitmapResultClass imageClass = step.GetBitmap(layers, boundsRelevantCMP, 500, 500);
      if (imageClass != null)
        imageClass.Image.Save(FileLocation + CMPforImage.Ref + ".png", System.Drawing.Imaging.ImageFormat.Png);