Software Companions Support Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
softcomp

Administrator
Registered:
Posts: 126
Reply with quote  #1 
The following sample code will load 7 different Gerber layers and then draw them all on an image using the ConvertGerberLayersToImageEx method.

scConverterLib.Converter myconverter;
myconverter = new scConverterLib.Converter();

myconverter.SetSerialNumber("Your Serial Number");

//Set background color and add all layers
myconverter.BackgroundColor = 0;
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/LAYER1.gbx", 0x0000FF, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/LAYER2.gbx", 0x00FF00, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/LAYER3.gbx", 0xFF0000, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/LAYER4.gbx", 0xFF00FF, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/CMASK.gbx", 0xFFFF00, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/SMASK.gbx", 0x00FFFF, 0);
myconverter.AddGerberLayer("http://www.gerbview.com/demo/gerbview/SILK.gbx", 0x0000aa, 0);

//Create image based on all layers
stdole.IPictureDisp scPicture = null;
myconverter.ConvertGerberLayersToImageEx(1.0, 24, 96, 0, ref scPicture);
Image image = PictureDispHost.GetPictureFromIPicture(scPicture);

At this point you have an Image that can be used for display and/or saving.

E.g.:

PictureBox1.Image = image

or
image.Save( @"c:\temp\test.png");


A complete C# sample can be downloaded here (VS2010):

http://www.softwarecompanions.no/dev/ConvertGerberLayersToImageExCS.zip

Previous Topic | Next Topic
Print
Reply

Quick Navigation: