Need help or advice ? Come to the Icy club ! - Every Wenesday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur
Register

Snapshot

by tprovoost / Thomas Provoost

Perform a snapshot and save the result into the selected file.

version 1 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: initial version
importClass(Packages.plugins.tprovoost.scripteditor.uitools.filedialogs.FileDialog)

importClass(Packages.icy.image.IcyBufferedImage)
importClass(Packages.icy.file.FileUtil)
importClass(Packages.icy.file.Saver)

importClass(Packages.java.io.File)

/*
 * In Icy, the snapshot feature is a part of the viewer, 
 * not the sequence. Indeed, the sequence is a container, 
 * only the viewer displays the image.
 */

// get the viewer and test if exists.
viewer = gui.getFocusedViewer()
if (viewer == null) throw "No sequence opened"

// Get the rendered Image
img = viewer.getCanvas().getRenderedImage(viewer.getT(), viewer.getZ(), -1, false)
img = IcyBufferedImage.createFrom(img)

// Open a File Dialog for saving, and test if selected one.
file = FileDialog.save()
if (file == null) throw "No file selected"

// Check if the file has an extension. Add .png if not.
if (FileUtil.getFileExtension(file.getPath(), false) == "")
	file = new File(file.getAbsolutePath() + ".png")

Saver.saveImage(img, file, true)

This script has no documentation. A Problem ? ask the community.



Icy script publication Id : R6I2L2