Minimum Origin Version Required: Origin 8 SR1
Prior to running the following example, the image_utils.c file needs to be loaded and compiled. This can be done from script with the following command or just add this file to your workspace.
run.LoadOC(Originlab\image_utils.c);
The matrix object of any data type can be exported as an image file. Before running the following example need to open new a matrix window and choose File: Import: Image... to import an image into the matrix window. Then run the following example to export the matrix object in this project as gray-scale image to the User Files Folder.
#include <image_utils.h> //export image from matrix void export_image() { // get the matrix page in project MatrixPage mp = Project.MatrixPages(0); if (!mp) { out_str("Failed to get the matrix page!\n"); return; } // get the matrix layer in the matrix page MatrixLayer ml = mp.Layers(0); if (!ml) { out_str("Get no matrix layer!\n"); return; } // get the matrix object in the matrix layer MatrixObject mo = ml.MatrixObjects(0); if (!mo) { out_str("Get no matrix object!\n"); return; } string strPageName; // get the matrix page name mp.GetName(strPageName); // the exported image type: png string strImageType = "png"; // path of image string strImagePath = GetAppPath(false) + strPageName + "." + strImageType; // the resolution of the image int nDPI = 300; // set the image as grayscale bool bGray = true; // export matrix object as image int nRet = export_Matrix_to_image(strImagePath, strImageType, mo, nDPI, bGray); if (nRet != 0) out_str("Failed to export matrix object as image!\n"); }