Snapshot.sml

  Download

More scripts: Display Toolbar

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
##########################
# Snapshot.sml
#
# Updated 27 March 2008  RBS
#
# Requires TNTmips 2005:72
#
##########################
#
# View MacroScript 
# 
# The following symbols are predefined 
#    class GRE_VIEW View      {use to access the view the script is run from} 
#    string MenuChoice$   {will contain the text from the selected menu choice if the button type is "menu"} 
#
##########################
class RVC_RASTER rast, ras;
class MieJPEG jpegHandle;
class MiePNG pngHandle;
class MieBMP bmpHandle;
class MieTIFF tiffHandle;
class MieGIF gifHandle;
class MiePCX pcxHandle;
class MieASCIIRASTER asciiHandle;
# This is the easiest way to get a temporary file without 
# having to worry about filnames already being used.
# Create a temporary raster and then get the filename from it.
CreateTempRaster(rast, 1, 1, "binary");
# Get the snapshot.
View.SaveSnapshot(rast.$Info.Filename, "snap", "snapshot of view");
# Export and open the snapshot.
if (MenuChoice$ == "JPEG") {
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 24);
	CloseRaster(ras);
	jpegHandle.exportCompressFactor = 75;
	ExportRaster(jpegHandle, _context.ScriptDir + "snapshot.jpg", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.jpg");
	}
else if (MenuChoice$ == "PNG") {
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 24);
	CloseRaster(ras);
	ExportRaster(pngHandle, _context.ScriptDir + "snapshot.png", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.png");
	}
else if (MenuChoice$ == "BMP") {
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 24);
	CloseRaster(ras);
	ExportRaster(bmpHandle, _context.ScriptDir + "snapshot.bmp", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.bmp");
	}
else if (MenuChoice$ == "PCX") {
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 8);
	CloseRaster(ras);
	ExportRaster(pcxHandle, _context.ScriptDir + "snapshot.pcx", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.pcx");
	}
else if (MenuChoice$ == "GIF") {
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 8);
	CloseRaster(ras);
	ExportRaster(gifHandle, _context.ScriptDir + "snapshot.gif", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.gif");
	}
else if (MenuChoice$ == "TIFF") {
	tiffHandle.CompressionType = "NONE";
	tiffHandle.PlanarConfiguration = "Pixel interleaved";
	tiffHandle.ExportGeoTags = 1;
	OpenRaster(ras, rast.$Info.Filename, "snap");
	ConvertCompToComp(ras, rast.$Info.Filename, "snapa", 24);
	CloseRaster(ras);
	ExportRaster(tiffHandle, _context.ScriptDir + "snapshot.tif", rast.$Info.Filename, "snapa");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.tif");
	}
else if (MenuChoice$ == "TXT") {
	ExportRaster(asciiHandle, _context.ScriptDir + "snapshot.txt", rast.$Info.Filename, "snap");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.txt");
	}
else if (MenuChoice$ == "DOC") {
	ExportRaster(asciiHandle, _context.ScriptDir + "snapshot.doc", rast.$Info.Filename, "snap");
	RunAssociatedApplication(_context.ScriptDir + "snapshot.doc");
	}
# Delete the temporary file.
DeleteTempRaster(rast);