Load a binary file that are in the form of a 2d array into a matrix object.
int okoc_binary_mat_import( LPCSTR lpcszFilename, LPCSTR lpcszRangeMat, int nCols, int nElemSize, int nSign, BOOL bBigEndian = false, int nOffset = 0, int nRows = -1 )
0 if success, < 0 for error codes, some important ones are
-20 lpcszRangeMat does not point to an existing MatrixObject
-1 lpcszFilename not found or size = 0
-2 lpcszFilename file size too small, does not even have a single row of data
-3 the combincation of nElemSize and nSign does not indicate a valid internal data type in Origin
-6 memory allocation failed to prepare the matrix object before import
-10 file size not exactly correct so failed to read the last row
-11 failed to open the file for reading
EX1
#include <okocUtils.h> void okoc_binary_mat_import_ex1() { string strFile = "C:\\temp4096x5120.img"; if ( strFile.IsFile() ) { const int nCols = 128; //number of columns in the matrix const int nBytes = 2; const int nSign = 0; const int nBigEnd = 0; const int nOffset = 0; string strRange; MatrixPage mp; mp.Create("Origin"); strRange.Format("[%s]1!1", mp.GetName()); int nRet = okoc_binary_mat_import(strFile, strRange, nCols, nBytes, nSign, nBigEnd, nOffset); if ( nRet == 0 ) out_str("Import binary data from file successfully."); else out_str("Fail to import binary data from file."); } return; }
okocUtils.h