Gatan | AMETEKSkip to Main Content
No options found

Import an image from a text file

DigitalMicrograph Script

Command example script showing how the ImageImportTextData() command is to be used.

Preview

// This script example shows the import text functionality
// It provides the same functionality as the menu: "File/Import Data..."
void ImportFromText()
{
	string path
	if ( !OpenDialog( NULL, "Import image from textfile" , path , path ) ) return
	number fileID = OpenFileForReading( path )
	object fStream = NewStreamFromFileReference( fileID , 1 )   // 1 for auto-close file when out of scope
	number endian = 1 //  1 = bigendian, 2 = littleendian

    number bLinesAreRows    = 1
    number bSizeByCount     = 1 
    number kREAL4_DATA      = 2
    if ( !bLinesAreRows )
		bSizeByCount = 0

    object imgSizeObj = Alloc( "ImageData_ImageDataSize" )
    image img := ImageImportTextData( "Imag Name " , fStream , kREAL4_DATA , imgSizeObj , bLinesAreRows , bSizeByCount )
    img.ShowImage()
}
ImportFromText()