當前位置: 首頁>>代碼示例>>Java>>正文


Java FileImageInputStream.close方法代碼示例

本文整理匯總了Java中javax.imageio.stream.FileImageInputStream.close方法的典型用法代碼示例。如果您正苦於以下問題:Java FileImageInputStream.close方法的具體用法?Java FileImageInputStream.close怎麽用?Java FileImageInputStream.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.stream.FileImageInputStream的用法示例。


在下文中一共展示了FileImageInputStream.close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import javax.imageio.stream.FileImageInputStream; //導入方法依賴的package包/類
/**
 * Reads the meta data from the file or input stream that has been set on
 * the constructor.
 */
public void read() throws IOException {
    if (file != null) {
        iin = new FileImageInputStream(file);
    }
    try {
        iin.seek(0);
        // Determine file type
        int magic = iin.readInt();
        iin.seek(0);
        if (magic == 0x49492a00) {
            // Little-Endian TIFF File
            // XXX - Implement Little-Endian TIFF File support
        } else if (magic == 0x4d4d002a) {
            // Big-Endian TIFF File
            // XXX - Implement Big-Endian TIFF File support
        } else if (magic == 0x52494646) {
            // Little-Endian RIFF File
            readRIFF(iin);
        } else {
            // JFIF File
            readJFIF(iin);
        }
    } finally {
        if (file != null) {
            iin.close();
        }
    }
}
 
開發者ID:pojosontheweb,項目名稱:selenium-utils,代碼行數:33,代碼來源:EXIFReader.java

示例2: recodeImages

import javax.imageio.stream.FileImageInputStream; //導入方法依賴的package包/類
/**
 * Recodes the images from the source transfer syntax, as read from the src
 * file, to the specified destination syntax.
 */
public void recodeImages(File src, File dest) throws IOException {
    ImageReader reader = new DicomImageReaderSpi().createReaderInstance();
    ImageWriter writer = new DicomImageWriterSpi().createWriterInstance();
    FileImageInputStream input = new FileImageInputStream(src);
    reader.setInput(input);
    if (dest.exists()) {
        dest.delete();
    }
    FileImageOutputStream output = new FileImageOutputStream(dest);
    writer.setOutput(output);
    DicomStreamMetaData streamMeta = (DicomStreamMetaData) reader.getStreamMetadata();
    DicomObject ds = streamMeta.getDicomObject();
    DicomStreamMetaData writeMeta = (DicomStreamMetaData) writer.getDefaultStreamMetadata(null);
    DicomObject newDs = new BasicDicomObject();
    ds.copyTo(newDs);
    writeMeta.setDicomObject(newDs);
    int frames = ds.getInt(Tag.NumberOfFrames, 1);
    LookupTable lut = prepareBitStrip(writeMeta, reader);
    newDs.putString(Tag.TransferSyntaxUID, VR.UI, destinationSyntax.uid());
    if (overwriteObject != null) {
        overwriteObject.copyTo(newDs);
    }
    writer.prepareWriteSequence(writeMeta);
    for (int i = 0; i < frames; i++) {
        WritableRaster r = (WritableRaster) reader.readRaster(i, null);
        ColorModel cm = ColorModelFactory.createColorModel(ds);
        BufferedImage bi = new BufferedImage(cm, r, false, null);
        if (lut != null) {
            lut.lookup(bi.getRaster(), bi.getRaster());
        }
        IIOImage iioimage = new IIOImage(bi, null, null);
        writer.writeToSequence(iioimage, null);
    }
    writer.endWriteSequence();
    output.close();
    input.close();
}
 
開發者ID:Sofd,項目名稱:viskit,代碼行數:42,代碼來源:Dcm2Dcm.java

示例3: showPreviewImage

import javax.imageio.stream.FileImageInputStream; //導入方法依賴的package包/類
/**
 * Writes the preview image into the servlet response
 * @return
 */
public String showPreviewImage() {
	File imgFile = null;
	if(!leaf) {

		String folderDirectory = "";
		if("projects-ticon".equals(iconCls)) {
			folderDirectory = ApplicationBean.getInstance().getServletContext().getRealPath("/"+Constants.DESIGN_DIRECTORY + "/" + Constants.DEFAULTDESIGNPATH + "/img/project.png");
		}else {
			folderDirectory = ApplicationBean.getInstance().getServletContext().getRealPath("/"+Constants.DESIGN_DIRECTORY + "/" + Constants.DEFAULTDESIGNPATH + "/img/folder.png");
		}
		imgFile = new File(folderDirectory);
	}else {
		File templateDir=ReportBL.getDirTemplate(templateID);
		String imageName = (String)descriptionMap.get(IDescriptionAttributes.PREVIEW_GIF);
		imgFile = new File(templateDir,imageName);
	}
	if (templateID!=null) {
		if (imgFile!=null && imgFile.exists()) {
			try {
				FileImageInputStream input = new FileImageInputStream(imgFile);
				ByteArrayOutputStream output = new ByteArrayOutputStream();
				byte[] buf = new byte[1024];
				byte[] data;
				int numBytesRead;
				while ((numBytesRead = input.read(buf)) != -1) {
					output.write(buf, 0, numBytesRead);
				}
				data = output.toByteArray();
				output.close();
				input.close();
				servletResponse.setContentType("image/gif");
				OutputStream outputStream = servletResponse.getOutputStream();
				outputStream.write(data);
				outputStream.flush();
			} catch (Exception e) {
				LOGGER.warn("Getting the preview image failed with " + e.getMessage());
				LOGGER.debug(ExceptionUtils.getStackTrace(e));
			}
		}
	}
	return null;
}
 
開發者ID:trackplus,項目名稱:Genji,代碼行數:47,代碼來源:ReportExecuteAction.java

示例4: write

import javax.imageio.stream.FileImageInputStream; //導入方法依賴的package包/類
public void write(PictureSubtitleList s, File file) throws IOException,
			FileNotFoundException {
		f = new EasyJaSubXmlWriter(file);

        writeln("<BDN Version=\"0.93\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"BD-03-006-0093b BDN File Format.xsd\">");
		writeln("<Description>");
		writeln("  <Name Title=\"" + s.getTitle() + "\" Content=\"\"/>");
		writeln("  <Language Code=\"jpn\" />");
		writeln("  <Format VideoFormat=\"" + videoFormat + "\" FrameRate=\"" + fpsStr + "\" DropFrame=\"False\" />");
		String firstTC = getTimeStamp(s.first().getStartTime());
		String lastTC = getTimeStamp(s.last().getEndTime());
		writeln("  <Events Type=\"Graphic\" FirstEventInTC=\"" + firstTC + "\" LastEventOutTC=\"" + lastTC + "\"");
// ContentInTC=\"" + firstTC + "\" ContentOutTC=\"" + lastTC + "\"
		writeln("    NumberofEvents=\"" + s.size() + "\" />");
		writeln("</Description>");
		writeln("<Events>");

		int videoWidth = command.getWidth();
		int videoHeight = command.getHeight();
		for (PictureSubtitleLine l : s) {
			File imageFile = l.getPngFile();
			if (!imageFile.canRead()) {
				throw new IOException("Can not read file " + imageFile.getAbsolutePath());
			}
			FileImageInputStream is = new FileImageInputStream(imageFile);
			ir.setInput(is);
			int width = ir.getWidth(0);
			int height = ir.getHeight(0);
			ir.setInput(null);
			is.close();

			String inTC = getTimeStamp(l.getStartTime());
			String outTC = getTimeStamp(l.getEndTime());

			int x = (videoWidth - width) / 2;
			int y = (videoHeight - height - 20);
			String pngFileName = l.getPngFile().getName();
			
			writeln("  <Event InTC=\""+ inTC + "\" OutTC=\""+ outTC + "\" Forced=\"False\">");
			writeln("    <Graphic Width=\"" + width + "\" Height=\""+ height 
					+ "\" X=\"" + x + "\" Y=\"" + y + "\">" + pngFileName + "</Graphic>");
			writeln("  </Event>");
		}
		writeln("</Events>");
		writeln("</BDN>");
		f.close();
	}
 
開發者ID:riccardove,項目名稱:easyjasub,代碼行數:48,代碼來源:SubtitleListBdnXmlFileWriter.java


注:本文中的javax.imageio.stream.FileImageInputStream.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。