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


Java ImageInputStream.readByte方法代码示例

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


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

示例1: main

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    MarkTryFinallyReproducerSpi spi = new MarkTryFinallyReproducerSpi();
    IIORegistry.getDefaultInstance().registerServiceProvider(spi);

    ImageInputStream iis1 =
      new NotClosingImageInputStream(ImageIO.createImageInputStream(new ByteArrayInputStream(bmp)));
    iis1.readByte();
    iis1.mark();
    long p1 = iis1.getStreamPosition();
    iis1.readByte();
    iis1.mark();
    long p2 = iis1.getStreamPosition();
    BufferedImage bi1 = ImageIO.read(iis1);
    iis1.reset();
    long pn2 = iis1.getStreamPosition();
    iis1.reset();
    long pn1 = iis1.getStreamPosition();
    if (p1 != pn1 || p2!= pn2) {
        throw new RuntimeException("Exception from call to canDecodeInput in ImageIO. " +
                                   "Corrupted stack in ImageInputStream");
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MarkTryFinallyReproducer.java

示例2: readMultiByteInteger

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
public static int readMultiByteInteger(ImageInputStream iis)
    throws IOException
{
    int value = iis.readByte();
    int result = value & 0x7f;
    while((value & 0x80) == 0x80) {
        result <<= 7;
        value = iis.readByte();
        result |= (value & 0x7f);
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ReaderUtil.java

示例3: canDecodeInput

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
public boolean canDecodeInput(Object source) throws IOException {
    if (!(source instanceof ImageInputStream)) {
        return false;
    }

    ImageInputStream stream = (ImageInputStream)source;

    stream.mark();
    try {
        int type = stream.readByte();   // TypeField
        int fixHeaderField = stream.readByte();
        // check WBMP "header"
        if (type != 0 || fixHeaderField != 0) {
            // while WBMP reader does not support ext WBMP headers
            return false;
        }

        int width = ReaderUtil.readMultiByteInteger(stream);
        int height = ReaderUtil.readMultiByteInteger(stream);
        // check image dimension
        if (width <= 0 || height <= 0) {
            return false;
        }

        long dataLength = stream.length();
        if (dataLength == -1) {
            // We can't verify that amount of data in the stream
            // corresponds to image dimension because we do not know
            // the length of the data stream.
            // Assuming that wbmp image are used for mobile devices,
            // let's introduce an upper limit for image dimension.
            // In case if exact amount of raster data is unknown,
            // let's reject images with dimension above the limit.
            return (width < MAX_WBMP_WIDTH) && (height < MAX_WBMP_HEIGHT);
        }

        dataLength -= stream.getStreamPosition();

        long scanSize = (width / 8) + ((width % 8) == 0 ? 0 : 1);

        return (dataLength == scanSize * height);
    } finally {
        stream.reset();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:WBMPImageReaderSpi.java


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