当前位置: 首页>>代码示例>>Java>>正文


Java FileInfo类代码示例

本文整理汇总了Java中ij.io.FileInfo的典型用法代码示例。如果您正苦于以下问题:Java FileInfo类的具体用法?Java FileInfo怎么用?Java FileInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileInfo类属于ij.io包,在下文中一共展示了FileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compImage

import ij.io.FileInfo; //导入依赖的package包/类
/**
 * Comp image.
 *
 * @param compoImg the compo img
 * @param img the img
 * @return true, if successful
 */
private boolean compImage(ImagePlus compoImg, ImagePlus img) {
	boolean width = compoImg.getWidth() == img.getWidth();
	boolean height = compoImg.getHeight() == img.getHeight();
	boolean depth = compoImg.getStackSize() == img.getStackSize();
	FileInfo imgInfo = img.getFileInfo();
	compoInfo = compoImg.getFileInfo();
	boolean voxx, voxy, voxz;
	try {
		voxx = cmpsize(compoInfo.pixelWidth, imgInfo.pixelWidth);
		voxy = cmpsize(compoInfo.pixelHeight, imgInfo.pixelHeight);
		voxz = cmpsize(compoInfo.pixelDepth, imgInfo.pixelDepth);
	} catch (NullPointerException e) {
		voxx = true; voxy = true; voxz = true;
	}
	System.out.println(voxx + " " + voxy +" " + voxz);
	
	return width && height && depth && voxx && voxy && voxz;
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:26,代码来源:ImageTable.java

示例2: fileInfo

import ij.io.FileInfo; //导入依赖的package包/类
private void fileInfo() {
	FileInfo fi = new FileInfo();
	try {
		fi = this.getFileInfo();
	} catch (final NullPointerException npe) {
	}
	fi.pixelWidth = VoxelSize;
	fi.pixelHeight = VoxelSize;
	fi.width = PicMatrixX;
	fi.height = PicMatrixY;
	fi.valueUnit = "mm";
	fi.fileName = fileName;
	fi.info = properties;
	fi.fileFormat = FileInfo.RAW;
	fi.compression = FileInfo.COMPRESSION_NONE;
	fi.fileType = FileInfo.GRAY16_SIGNED; //
	this.setFileInfo(fi);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:Read_Stratec_File.java

示例3: getFilePathFromImagePlus

import ij.io.FileInfo; //导入依赖的package包/类
private static String getFilePathFromImagePlus(ImagePlus imp) {
	// Try to get path first from image info property
	// (The info property should persist despite duplication, but the FileInfo probably doesn't)
	String info = imp.getInfoProperty();
	String path = null;
	if (info != null) {
		for (String s : GeneralTools.splitLines(info)) {
			if (s.toLowerCase().startsWith("location")) {
				path = s.substring(s.indexOf('=')+1).trim();
				break;
			}
		}
	}// If we haven't got a path yet, try the FileInfo
	if (path == null) {
		// Check the file info
		FileInfo fi = imp.getOriginalFileInfo();
		if (fi == null)
			return null;
		path = fi.directory + fi.fileName;
	}
	File file = new File(path);
	if (file.exists())
		return file.getAbsolutePath();
	return null;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:26,代码来源:ImagePlusServerBuilder.java

示例4: writeRawImage

import ij.io.FileInfo; //导入依赖的package包/类
private static void writeRawImage(final ImagePlus imp, final FileOutputStream fileOutputStream) throws MiException {
    final FileInfo fileInfo = imp.getFileInfo();
    fileInfo.fileFormat = FileInfo.RAW;
    // Eric Nodwell:
    // The following line is basically a bug work-around as far as I can
    // tell, as getFileInfo() ought to set virtualStack if the ImagePlus
    // is a VirtualStack.  In 1.44 it does not.
    final ImageStack imageStack = imp.getStack();
    if (imageStack.isVirtual() && imageStack instanceof VirtualStack) {
        fileInfo.virtualStack = (VirtualStack) imp.getStack();
    }

    try {
        final ImageWriter imageWriter = new ImageWriter(fileInfo);
        imageWriter.write(fileOutputStream);
    } catch (final IOException ex) {
        throw new MiException(ex);
    }
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:20,代码来源:MiEncoder.java

示例5: writeImage

import ij.io.FileInfo; //导入依赖的package包/类
void writeImage(FileInfo fi, Calibration cal) throws IOException {
	FileOutputStream out = new FileOutputStream(new File(fi.directory, fi.fileName));
	// First write out the full header
	Writer bw = new BufferedWriter(new OutputStreamWriter(out));
	// Blank line terminates header
	bw.write(makeHeader(fi,cal)+"\n");
	// Flush rather than close
	bw.flush();		

	// Then the image data
	ImageWriter writer = new ImageWriter(fi);
	if(nrrdEncoding.equals("gzip")) {
		GZIPOutputStream zStream = new GZIPOutputStream(new BufferedOutputStream( out ));
		writer.write(zStream);
		zStream.close();
	} else {
		writer.write(out);
		out.close();
	}
	IJ.showStatus("Saved "+ fi.fileName);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:22,代码来源:NrrdFileWriter.java

示例6: imgType

import ij.io.FileInfo; //导入依赖的package包/类
public static String imgType(int fiType) {
	switch (fiType) {
		case FileInfo.GRAY32_FLOAT:
			return "float";
		case FileInfo.GRAY32_INT:
			return "int32";
		case FileInfo.GRAY32_UNSIGNED:
			return "uint32";
		case FileInfo.GRAY16_SIGNED:
			return "int16";	
		case FileInfo.GRAY16_UNSIGNED:
			return "uint16";
	
		case FileInfo.COLOR8:
		case FileInfo.GRAY8:
			return "uint8";
		default:
			return "unsupported";
	}
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:21,代码来源:NrrdFileWriter.java

示例7: createInputStream

import ij.io.FileInfo; //导入依赖的package包/类
public InputStream createInputStream(FileInfo fi) throws IOException, MalformedURLException {
	// use the method in the FileOpener class to generate an input stream
	InputStream is=super.createInputStream(fi);

	// Skip if required
	if (preOffset!=0) is.skip(preOffset);

	// Just return orgiinal input stream if uncompressed
	if (gunzipMode==UNCOMPRESSED) return is;

	//  else put a regular GZIPInputStream on top 
	// NB should only do this if less than 138s because that will take 
	// care of things automatically
	
	if(gunzipMode==GZIP){
		boolean lessThan138s = IJ.getVersion().compareTo("1.38s")<0;
		if(lessThan138s) return new GZIPInputStream(is);
		else return is;
	}
	
	// or put a ZInputStream on top (from jzlib)
	if(gunzipMode==ZLIB) return new ZInputStream(is);
	
	// fallback
	throw new IOException("Incorrect GZIP mode: "+gunzipMode);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:27,代码来源:FlexibleFileOpener.java

示例8: saveRawDataGrid

import ij.io.FileInfo; //导入依赖的package包/类
/**
 * Method to write a Grid to raw disk space.
 * @param grid the grid to write
 * @param fileInfo the file into that describes the raw data file format
 * @param os the stream to write to 
 * @throws IOException may occur, if we run out of diskspace or have an invalid filename
 */
public static void saveRawDataGrid(NumericGrid grid, FileInfo fileInfo, OutputStream os) throws IOException{
	if (grid instanceof Grid1D){
		saveRawDataGrid((Grid1D)grid, fileInfo, os);
		return;
	}
	if (grid instanceof Grid2D){
		saveRawDataGrid((Grid2D)grid, fileInfo, os);
		return;
	}
	if (grid instanceof Grid3D){
		saveRawDataGrid((Grid3D)grid, fileInfo, os);
		return;
	}
	throw new RuntimeException("This subtype of grid is not implemented.");
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:23,代码来源:GridRawIOUtil.java

示例9: loadFromRawData

import ij.io.FileInfo; //导入依赖的package包/类
/**
 * Method to load a Grid from raw data.
 * @param fileInfo describes the file format
 * @param filename the file location
 * @return the grid
 */
public static NumericGrid loadFromRawData(FileInfo fileInfo, String filename){
	String sep = System.getProperty("file.separator");
	String [] fileSplit = filename.split("\\"+ sep);
	String file = fileSplit[fileSplit.length-1];
	String path = fileSplit[0];
	for (int i = 1; i < fileSplit.length-1;i++){
		path += sep + fileSplit[i];
	}
	fileInfo.fileName = file;
	fileInfo.directory = path;
	FileOpener fO = new FileOpener(fileInfo);
	ImagePlus image = fO.open(false);
	
	if (!(image.getProcessor() instanceof FloatProcessor)) {
		ImageConverter converter = new ImageConverter(image);
		converter.convertToGray32();
	}
	NumericGrid grid = null;
	if (fileInfo.nImages>1){
		 grid = ImageUtil.wrapImagePlus(image);
	} else {
		grid = ImageUtil.wrapFloatProcessor((FloatProcessor) image.getProcessor());
	}
	return grid;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:32,代码来源:GridRawIOUtil.java

示例10: createInputStream

import ij.io.FileInfo; //导入依赖的package包/类
/** Returns an InputStream for the image described by this FileInfo. */
protected InputStream createInputStream(FileInfo fi) throws IOException, MalformedURLException {
	InputStream is = null;
	boolean gzip = fi.fileName!=null && (fi.fileName.endsWith(".gz")||fi.fileName.endsWith(".GZ"));
	if (fi.inputStream!=null)
		is = fi.inputStream;
	else if (fi.url!=null && !fi.url.equals(""))
		is = new URL(fi.url+fi.fileName).openStream();
	else {
		if (fi.directory.length()>0 && !fi.directory.endsWith(Prefs.separator))
			fi.directory += Prefs.separator;
		File f = new File(fi.directory + fi.fileName);
		if (gzip) fi.compression = FileInfo.COMPRESSION_UNKNOWN;
		if (f==null || f.isDirectory() || !validateFileInfo(f, fi))
			is = null;
		else
			is = new FileInputStream(f);
	}
	if (is!=null) {
		if (fi.compression>=FileInfo.LZW)
			is = new RandomAccessStream(is);
		else if (gzip)
			is = new GZIPInputStream(is, 50000);
	}
	return is;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:27,代码来源:FileProjectionSource.java

示例11: validateFileInfo

import ij.io.FileInfo; //导入依赖的package包/类
protected static boolean validateFileInfo(File f, FileInfo fi) {
	long offset = fi.getOffset();
	long length = 0;
	if (fi.width<=0 || fi.height<0) {
		error("Width or height <= 0.", fi, offset, length);
		return false;
	}
	if (offset>=0 && offset<1000L)
		return true;
	if (offset<0L) {
		error("Offset is negative.", fi, offset, length);
		return false;
	}
	if (fi.fileType==FileInfo.BITMAP || fi.compression!=FileInfo.COMPRESSION_NONE)
		return true;
	length = f.length();
	long size = fi.width*fi.height*fi.getBytesPerPixel();
	size = fi.nImages>1?size:size/4;
	if (fi.height==1) size = 0; // allows plugins to read info of unknown length at end of file
	if (offset+size>length) {
		error("Offset + image size > file length.", fi, offset, length);
		return false;
	}
	return true;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:26,代码来源:FileProjectionSource.java

示例12: readPixels

import ij.io.FileInfo; //导入依赖的package包/类
/** Reads the pixel data from an image described by a FileInfo object. */
protected Object readPixels(FileInfo fi) {
	Object pixels = null;
	try {
		InputStream is = createInputStream(fi);
		if (is==null)
			return null;
		ImageReader reader = new ImageReader(fi);
		pixels = reader.readPixels(is);
		is.close();
	}
	catch (Exception e) {
		if (!Macro.MACRO_CANCELED.equals(e.getMessage()))
			IJ.handleException(e);
	}
	return pixels;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:18,代码来源:FileProjectionSource.java

示例13: openFileList

import ij.io.FileInfo; //导入依赖的package包/类
private ImagePlus openFileList(File [] files, FileInfo fi){
	ImagePlus image = null;
	if (fi.nImages > 1){
		ImageStack stack = null;
		for (File file: files){
			ImagePlus img = openImage(file, fi);
			if (stack == null) stack = new ImageStack(img.getWidth(), img.getHeight());
			for (int i =1; i <= img.getStackSize(); i++){
				stack.addSlice("slice " + i, img.getStack().getProcessor(i));
			}
		}
		image = new ImagePlus();
		image.setStack(files[0].getName(), stack);
		image.setOpenAsHyperStack(true);
		image.setDimensions(1, fi.nImages, files.length);
	} else {
		image = openImageSequence(files, fi);
	}
	return image;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:21,代码来源:RawDataOpener.java

示例14: validateFileInfo

import ij.io.FileInfo; //导入依赖的package包/类
protected boolean validateFileInfo(File f, FileInfo fi) {
	long offset = fi.getOffset();
	long length = 0;
	if (fi.width<=0 || fi.height<0) {
		error("Width or height <= 0.", fi, offset, length);
		return false;
	}
	if (offset>=0 && offset<1000L)
		return true;
	if (offset<0L) {
		error("Offset is negative.", fi, offset, length);
		return false;
	}
	if (fi.fileType==FileInfo.BITMAP || fi.compression!=FileInfo.COMPRESSION_NONE)
		return true;
	length = f.length();
	long size = fi.width*fi.height*fi.getBytesPerPixel();
	size = fi.nImages>1?size:size/4;
	if (fi.height==1) size = 0; // allows plugins to read info of unknown length at end of file
	if (offset+size>length) {
		error("Offset + image size > file length.", fi, offset, length);
		return false;
	}
	return true;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:26,代码来源:ZIP_Reader_Standalone.java

示例15: createNote

import ij.io.FileInfo; //导入依赖的package包/类
private HashMap<String, String> createNote()
{
	HashMap<String, String> note = new HashMap<String, String>();
	note.put("Created", new SimpleDateFormat("d-MMM-yyyy HH:mm").format(new Date()));
	FileInfo info = imp.getOriginalFileInfo();
	if (info != null)
	{
		note.put("File", info.fileName);
		note.put("Dir", info.directory);
	}
	else
	{
		note.put("Title", imp.getTitle());
	}
	return note;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:17,代码来源:PSFCreator.java


注:本文中的ij.io.FileInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。