{"id":217,"date":"2022-10-10T10:15:57","date_gmt":"2022-10-10T08:15:57","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=217"},"modified":"2022-10-10T13:49:35","modified_gmt":"2022-10-10T11:49:35","slug":"how-to-make-images-of-components","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-make-images-of-components\/","title":{"rendered":"How to make images of components"},"content":{"rendered":"\n<p><strong>Here is the example code in C Sharp and VB:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo9VBCode.zip\" target=\"_blank\" rel=\"noopener\">download VB<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo9CSharp.zip\" target=\"_blank\" rel=\"noopener\">download C#<\/a><\/li><\/ul>\n\n\n\n<p>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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/for current view you can use this example:\nBitmap curView = mainWindowPCBI.GetCurrentPicture();\ncurView.Save(@\"C:\\E\\tests\\curView.png\", System.Drawing.Imaging.ImageFormat.Png);<\/code><\/pre>\n\n\n\n<p>Otherwise you can use the step to create an image of a layer list and a defined area:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>IPCBIWindow mainWindowPCBI; \/\/fill e.g. in load or on other button click with mainWindowPCBI = IAutomation.CreateNewPCBIWindow(true);\n    private void buttonExportImage_Click(object sender, EventArgs e)\n    {\n      IStep step = mainWindowPCBI.GetCurrentStep();\n      if (step == null) return;\n      \n      ICMPLayer layerCMPsTop = step.GetCMPLayer(true);\n      \/\/exisits the compnenent layer?\n      if (layerCMPsTop == null) return;\n \n      List&lt;IObject&gt; layerObjectList = layerCMPsTop.GetAllLayerObjects();\n      \/\/is there a compnent on the layer?\n      if (layerObjectList.Count == 0) return;\n \n      \/\/for the example we use the first component, you can search for each component attribut you want\n      SaveImageFromComponent((ICMPObject)layerObjectList&#91;0], step, @\"C:\\E\\tests\\\");\n \n      \/\/something went wrong?\n      string errorLog = IAutomation.GetErrorLog();\n      if(errorLog.Length&gt;0)\n        System.Diagnostics.Debug.WriteLine(errorLog);\n    }\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ This example shows how to make an image of an component with connections on the signal layer below.\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=\"CMPforImage\"&gt;The relevant component&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"step\"&gt;current step from the component&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"FileLocation\"&gt;Where should we save the image?&lt;\/param&gt;\n    public void SaveImageFromComponent(ICMPObject CMPforImage, IStep step, string FileLocation)\n    {\n      List&lt;ILayer&gt; layers = new List&lt;ILayer&gt;(); \/\/for the image we need all layers who are visible\n \n      ICMPLayer CMPlayer = step.GetCMPLayer(CMPforImage.PlacedTop);\n      IODBLayer outsideSignalLayer = step.GetOutsideODBLayer(CMPforImage.PlacedTop);\n \n      if (CMPlayer == null) return; \/\/check the layer is existing? maybe wrong job?\n      layers.Add(CMPlayer);\n \n      if (outsideSignalLayer != null) \/\/we want to see where are pins connected\n        layers.Add(outsideSignalLayer);\n \n      RectangleF boundsRelevantCMP = CMPforImage.GetBounds();\n      boundsRelevantCMP.Inflate(100, 100); \/\/show a little bit of the area around the component\n \n      \/\/create the image and save it as png\n      PCBI.Automation.IStep.BitmapResultClass imageClass = step.GetBitmap(layers, boundsRelevantCMP, 500, 500);\n      if (imageClass != null)\n        imageClass.Image.Save(FileLocation + CMPforImage.Ref + \".png\", System.Drawing.Imaging.ImageFormat.Png);\n \n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is the example code in C Sharp and VB: download VB download C# 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: Otherwise you can use the step to create an image of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":246,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-217","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/217\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/217\/revisions\/218"}],"up":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/246"}],"wp:attachment":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}