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


Java IoUtils.closeQuietly方法代码示例

本文整理汇总了Java中org.apache.commons.imaging.util.IoUtils.closeQuietly方法的典型用法代码示例。如果您正苦于以下问题:Java IoUtils.closeQuietly方法的具体用法?Java IoUtils.closeQuietly怎么用?Java IoUtils.closeQuietly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.imaging.util.IoUtils的用法示例。


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

示例1: getBufferedImage

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public final BufferedImage getBufferedImage(final ByteSource byteSource,
        Map<String, Object> params) throws ImageReadException, IOException {
    params = (params == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
    boolean isStrict = false;
    final Object strictness = params.get(PARAM_KEY_STRICT);
    if (strictness != null) {
        isStrict = ((Boolean) strictness).booleanValue();
    }

    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final PcxHeader pcxHeader = readPcxHeader(is, isStrict);
        final BufferedImage ret = readImage(pcxHeader, is, byteSource);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:23,代码来源:PcxImageParser.java

示例2: getAllBufferedImages

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public List<BufferedImage> getAllBufferedImages(final ByteSource byteSource)
        throws ImageReadException, IOException {
    final DcxHeader dcxHeader = readDcxHeader(byteSource);
    final List<BufferedImage> images = new ArrayList<BufferedImage>();
    final PcxImageParser pcxImageParser = new PcxImageParser();
    for (final long element : dcxHeader.pageTable) {
        InputStream stream = null;
        boolean canThrow = false;
        try {
            stream = byteSource.getInputStream(element);
            final ByteSourceInputStream pcxSource = new ByteSourceInputStream(
                    stream, null);
            final BufferedImage image = pcxImageParser.getBufferedImage(
                    pcxSource, new HashMap<String, Object>());
            images.add(image);
            canThrow = true;
        } finally {
            IoUtils.closeQuietly(canThrow, stream);
        }
    }
    return images;
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:24,代码来源:DcxImageParser.java

示例3: readBmpHeaderInfo

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private BmpHeaderInfo readBmpHeaderInfo(final ByteSource byteSource,
        final boolean verbose) throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();

        // readSignature(is);
        final BmpHeaderInfo ret = readBmpHeaderInfo(is, null, verbose);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:16,代码来源:BmpImageParser.java

示例4: parseXpmHeader

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private XpmParseResult parseXpmHeader(final ByteSource byteSource)
        throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final StringBuilder firstComment = new StringBuilder();
        final ByteArrayOutputStream preprocessedFile = BasicCParser.preprocess(
                is, firstComment, null);
        if (!"XPM".equals(firstComment.toString().trim())) {
            throw new ImageReadException("Parsing XPM file failed, "
                    + "signature isn't '/* XPM */'");
        }

        final XpmParseResult xpmParseResult = new XpmParseResult();
        xpmParseResult.cParser = new BasicCParser(new ByteArrayInputStream(
                preprocessedFile.toByteArray()));
        xpmParseResult.xpmHeader = parseXpmHeader(xpmParseResult.cParser);
        canThrow = true;
        return xpmParseResult;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:25,代码来源:XpmImageParser.java

示例5: getBufferedImage

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String, Object> params)
        throws ImageReadException, IOException {
    final RgbeInfo info = new RgbeInfo(byteSource);
    boolean canThrow = false;
    try {
        // It is necessary to create our own BufferedImage here as the
        // org.apache.commons.imaging.common.IBufferedImageFactory interface does
        // not expose this complexity
        final DataBuffer buffer = new DataBufferFloat(info.getPixelData(),
                info.getWidth() * info.getHeight());

        final BufferedImage ret = new BufferedImage(new ComponentColorModel(
                ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                Transparency.OPAQUE, buffer.getDataType()),
                Raster.createWritableRaster(
                        new BandedSampleModel(buffer.getDataType(), info
                                .getWidth(), info.getHeight(), 3), buffer,
                        new Point()), false, null);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, info);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:26,代码来源:RgbeImageParser.java

示例6: setExifGPSTag

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
/**
 * This method sets the EXIF the of the JPEG file and outputs it to given directory.
 * @param jpegImageFile
 * 		Input jpeg file.
 * @param dst
 * 		output jpeg file.
 * @param longitude
 * 		Longitude to be tagged.
 * @param latitude
 * 	 	Latitude to be tagged.
 * @throws IOException
 * @throws ImageReadException
 * @throws ImageWriteException
 */
public static void setExifGPSTag(final File jpegImageFile, final File dst, final double longitude, final double latitude) throws IOException,
ImageReadException, ImageWriteException {
	OutputStream os = null;
	boolean canThrow = false;
	try {

		final IImageMetadata metadata = Imaging.getMetadata(jpegImageFile);
		final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
		TiffOutputSet outputSet = setTiffOutputSet(jpegMetadata, longitude, latitude);
		os = new FileOutputStream(dst);
		os = new BufferedOutputStream(os);
		new ExifRewriter().updateExifMetadataLossless(jpegImageFile, os, outputSet);
		canThrow = true;
	} finally {
		IoUtils.closeQuietly(canThrow, os);
	}
}
 
开发者ID:codailama,项目名称:GeoTagPhotos,代码行数:32,代码来源:EXIFUtils.java

示例7: readTiffHeader

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private TiffHeader readTiffHeader(final ByteSource byteSource) throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final TiffHeader ret = readTiffHeader(is);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:13,代码来源:TiffReader.java

示例8: readData

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public void readData(final InputStream is, final BufferedImage bi,
        final ImageContents imageContents, final BinaryFileParser bfp)
        throws ImageReadException, IOException {
    final PsdHeaderInfo header = imageContents.header;
    final int width = header.columns;
    final int height = header.rows;

    bfp.setDebug(false);

    final int channelCount = dataParser.getBasicChannelsCount();
    final int depth = header.depth;
    final MyBitInputStream mbis = new MyBitInputStream(is, ByteOrder.BIG_ENDIAN);
    // we want all samples to be bytes
    BitsToByteInputStream bbis = null;
    boolean canThrow = false;
    try {
        bbis = new BitsToByteInputStream(mbis, 8);

        final int[][][] data = new int[channelCount][height][width];
        for (int channel = 0; channel < channelCount; channel++) {
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x++) {
                    final int b = bbis.readBits(depth);

                    data[channel][y][x] = (byte) b;
                }
            }
        }

        dataParser.parseData(data, bi, imageContents);
        canThrow = true;
    } finally {
        IoUtils.closeQuietly(canThrow, bbis);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:37,代码来源:UncompressedDataReader.java

示例9: readDcxHeader

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private DcxHeader readDcxHeader(final ByteSource byteSource)
        throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final int id = read4Bytes("Id", is, "Not a Valid DCX File", getByteOrder());
        final List<Long> pageTable = new ArrayList<Long>(1024);
        for (int i = 0; i < 1024; i++) {
            final long pageOffset = 0xFFFFffffL & read4Bytes("PageTable", is,
                    "Not a Valid DCX File", getByteOrder());
            if (pageOffset == 0) {
                break;
            }
            pageTable.add(pageOffset);
        }

        if (id != DcxHeader.DCX_ID) {
            throw new ImageReadException(
                    "Not a Valid DCX File: file id incorrect");
        }
        if (pageTable.size() == 1024) {
            throw new ImageReadException(
                    "DCX page table not terminated by zero entry");
        }

        final Object[] objects = pageTable.toArray();
        final long[] pages = new long[objects.length];
        for (int i = 0; i < objects.length; i++) {
            pages[i] = ((Long) objects[i]);
        }

        final DcxHeader ret = new DcxHeader(id, pages);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:40,代码来源:DcxImageParser.java

示例10: read256ColorPaletteFromEndOfFile

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private int[] read256ColorPaletteFromEndOfFile(final ByteSource byteSource)
        throws IOException {
    InputStream stream = null;
    boolean canThrow = false;
    try {
        stream = byteSource.getInputStream();
        final long toSkip = byteSource.getLength() - 769;
        skipBytes(stream, (int) toSkip);
        final int[] ret = read256ColorPalette(stream);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, stream);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:16,代码来源:PcxImageParser.java

示例11: writeSegments

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
protected void writeSegments(final OutputStream os,
        final List<? extends JFIFPiece> segments) throws IOException {
    boolean canThrow = false;
    try {
        JpegConstants.SOI.writeTo(os);

        for (JFIFPiece piece : segments) {
            piece.write(os);
        }
        canThrow = true;
    } finally {
        IoUtils.closeQuietly(canThrow, os);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:15,代码来源:JpegRewriter.java

示例12: getImageSize

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public Dimension getImageSize(final ByteSource byteSource, final Map<String, Object> params)
        throws ImageReadException, IOException {
    final RgbeInfo info = new RgbeInfo(byteSource);
    boolean canThrow = false;
    try {
        final Dimension ret = new Dimension(info.getWidth(), info.getHeight());
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, info);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:14,代码来源:RgbeImageParser.java

示例13: deflate

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private byte[] deflate(final byte[] bytes) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DeflaterOutputStream dos = new DeflaterOutputStream(baos);
    boolean canThrow = false;
    try {
        dos.write(bytes);
        canThrow = true;
    } finally {
        IoUtils.closeQuietly(canThrow, dos);
    }
    return baos.toByteArray();
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:13,代码来源:PngWriter.java

示例14: readWbmpHeader

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
private WbmpHeader readWbmpHeader(final ByteSource byteSource)
        throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final WbmpHeader ret = readWbmpHeader(is);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:14,代码来源:WbmpImageParser.java

示例15: getBufferedImage

import org.apache.commons.imaging.util.IoUtils; //导入方法依赖的package包/类
@Override
public final BufferedImage getBufferedImage(final ByteSource byteSource,
        final Map<String, Object> params) throws ImageReadException, IOException {
    InputStream is = null;
    boolean canThrow = false;
    try {
        is = byteSource.getInputStream();
        final WbmpHeader wbmpHeader = readWbmpHeader(is);
        final BufferedImage ret = readImage(wbmpHeader, is);
        canThrow = true;
        return ret;
    } finally {
        IoUtils.closeQuietly(canThrow, is);
    }
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:16,代码来源:WbmpImageParser.java


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