QIS Library Logo

C# Code Example

We have been asked to show how QISLIB can be called from an application written in C#. The QISLIB API is based on C/C++ so the C# programmer must use certain approaches to work with the library.


What Does the Sample Code Do?

    The sample code, GDSExtract64.exe, runs from a command line. The user defines a file name to open (the file can be GDSII or OASIS and the type is automatically detected by the library.)

    The command line specifies whether the program is to extract GDSII or TIFF (bitmap) data.

    The command line points to a file that contains a list of extraction windows.

    The program extracts from this list of windows either a GDSII file or a TIFF bitmap depending on the extraction mode set on the command line.

Command Line Syntax

The command line syntax for the sample application called GDSExtract64.exe that will produce either TIFF or GDSII output is:

GDSExtract64.exe input_file window_list.txt -lyr:layer_list -output_type


GDSExtract64.exe        path/name of the sample program to execute.

input_file              full path to a GDSII or OASIS input file.

window_list.txt         an ascii text file containing a list of windows to extract.

-lyr:layer_list         a comma delimited list of layers to extract.

-output_type            choices are -tif or -gds. Determines type of output data.

The Window List

A more sophisticated program could get window information interactively or otherwise. However to keep this example as simple as possible the program reads the windows to extract from a text file. The file should follow the example shown below:

-1000,-500,13000,11500 14000,12000 C:\tmp\0_0.${EXT}
13000,-500,27000,11500 14000,12000 C:\tmp\0_1.${EXT}
27000,-500,41000,11500 14000,12000 C:\tmp\0_2.${EXT}
-1000,11500,13000,23500 14000,12000 C:\tmp\1_0.${EXT}
13000,11500,27000,23500 14000,12000 C:\tmp\1_1.${EXT}
27000,11500,41000,23500 14000,12000 C:\tmp\1_2.${EXT}
-1000,23500,13000,35500 14000,12000 C:\tmp\2_0.${EXT}
13000,23500,27000,35500 14000,12000 C:\tmp\2_1.${EXT}
27000,23500,41000,35500 14000,12000 C:\tmp\2_2.${EXT}

This table has 3 parameters per line, separated by a space.

  • The first parameter, consisting of four numerical values (comma delimited) define the LL and UR corners of the extraction window.

  • The second parameter, consisting of two numerical values (comma delimited) specify the width and height of a bitmap for tiff output. Ignored if GDSII output is selected

  • The third parameter is the output path and file name. The extentsion variable will be replaced by the calling application with either .tif for bitmaps or .gds for GDSII output.

QISLIB Functions Used by the Sample Code

Here is a list of the QISLib functions used by this sample code. This is, of course, only a very small subset of the available functions.


Initializes the Library. The license to execute is checked at this point.


Use to define which layers to import. This is different than turning layers on/off that have already been imported.


A directive telling the library to load all of the entity data into memory (the alternative is to leave entity data on disk.) This needs to be set prior to opening the input file.


A directive telling the library whether to load text entities. This needs to be set prior to opening the input file.


A directive telling QISLIB how to deal with arrays (AREF). There are three values: 0-ignore, 1-outer rows/columns only and 2-full array.


the function used to open a GDSII stream file. The calling app has already determined what the file type is, based on the first few bytes, and will pick either this function or the OpenOASIS function.


The function used to open an OASIS file.


function returns a summary (statistics) of the opened GDSII or OASIS file. This ise displayed to the user by the calling application.


Defines a data window. This window will be used on subsequent function calls for extraction.


Used to extract a GDSII file to disk based on the current defined window and which layers are currently on.


Used to produce a tiff bitmap based on the current window, which layers are turned on and size of the bitmap.


Once done, if we've opened a GDSII file we now close it.


Once done with our extractions, we close the OASIS file (if we opened an OASIS file.)


Close the library. This releases the license.

What's Supplied

When QISLib is installed, additional directories are created and populated with the C# sample source code, example data and batch files.


Artwork provides project, source and solution files for Microsoft Visual Studio 2010. It should be possible to build the sample application immediately using these files.