It occurs to me that with all this discussion on getting raw image data in and out of our applications I should make available the code we use to read/write Surfer GRD files. This is a proprietary format from Golden Software, but they freely provide documentation on the format. That said, sometimes it is easier to just read the damn code!
Attached below is the code module for reading and writing Surfer GRD files, though it is also available on the CalcZAF GitHub site:
https://github.com/openmicroanalysis/calczafThe VB6 code attached below has routines for the old v. 6 GRD format, though since about 2005 we only utilize v. 7 format which is the format used still today by Golden Software. The main read/write routine for the current GRD format is called (appropriately enough!), GridFileReadWrite2(). There are several other routines for reading the header data, and also for reading the GRDInfo.ini file which we create to indicate the stage units and polarity (cartesian for Cameca vs. anti-cartesian for JEOL).
That said, it is a really easy format and all the data is stored as 32 floats so almost any data type can be utilized. In fact the GRD format is the native format for CalcImage which is Probe Software's quantitative mapping software. This allows CalcImage to calculate, store and output fully quantitative x-ray map data whether it be net intensities, k-ratios, detection limits, weight%, atomic%, etc., etc.:
https://probesoftware.com/smf/index.php?topic=41.msg4167#msg4167