- Home
- Programming ZEMAX
- How to Create Binary IMA and BIM Files
How to Create Binary IMA and BIM Files
- By Sanjay Gangadhara
- Published 14 February 2008
- Programming ZEMAX
-
Rating:




Writing the code which generate the files
An example of a C code (Image files.c) used to generate a checkerboard illumination pattern is provided in the .ZIP file located at the end of this article. This code generates three types of files which are used by ZEMAX: an ASCII IMA file, a Binary IMA file, and a Binary BIM file. More information about these file types may be found in Chapter 7 of the ZEMAX manual, under the description for the Geometric Image Analysis feature. In this case, the illumination pattern generated in each file is a 5x5 checkerboard, where the intensity values alternate between 0 and 1 (or 255 for the case of the binary IMA file, which is the equivalent maximum value). ASCII IMA files may also be generated and edited with a text editor, of course. This code generates all types of IMA and BIM files that are supported by ZEMAX for completeness.
The code itself is straightforward. The initial part of the program is dedicated to specifying names for the three files, and then opening those files so that they may be written to:
After declaring variables that will be used later in the code and defining the size of the illumination array in x and y, the necessary header information necessary is written to each file:
Finally, illumination data are written to each file. The data alternate between minimum and maximum values, to produce a checkerboard pattern: