Create Black And White map of layerimage

There was a request how to get black and white images of signal layers, here is the script code without using the bool map at the end.
You have to copy this method and modify it for your own code, it only create the "black and White" map without using it.

public void Execute(IPCBIWindow parent)
if (parent == null) return;

IStep step = parent.GetCurrentStep(); //we need the current step to draw the image
if (step == null)
List activeLayerList = new List();
//for example add first signal layer
activeLayerList.Add(step.GetOutsideODBLayer(true)); //this works only if matrix definition is correct

System.Drawing.RectangleF VisibleBounds = step.GetBounds(); //what area is interesting?

System.Drawing.Bitmap bmp = step.GetBitmap(activeLayerList, VisibleBounds, 1000, 1000).Image;

if (bmp != null)
bool[,] bMap = new bool[1000,1000];

for (int x = 0; x < 1000; x++)
for (int y = 0; y < 1000; y++)
bMap[x,y] = bmp.GetPixel(x, y) != Color.Black;
//now you can work with bool instead of pixel values

By the way this is a very slow way to convert the image to bool values. It is better to work with byte arrays and pin the image to use unsafe code.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.