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


Java ImageInputStream.read方法代码示例

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


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

示例1: readByteBuffer

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
void readByteBuffer(ImageInputStream iis,
                    byte [] data,
                    JPEGImageReader reader,
                    float workPortion,
                    float workOffset) throws IOException {
    int progInterval = Math.max((int)(data.length/20/workPortion),
                                1);
    for (int offset = 0;
         offset < data.length;) {
        int len = Math.min(progInterval, data.length-offset);
        iis.read(data, offset, len);
        offset += progInterval;
        float percentDone = ((float) offset* 100)
            / data.length
            * workPortion + workOffset;
        if (percentDone > 100.0F) {
            percentDone = 100.0F;
        }
        reader.thumbnailProgress (percentDone);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:JFIFMarkerSegment.java

示例2: canDecodeInput

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
public boolean canDecodeInput(Object source) throws IOException {
    if (!(source instanceof ImageInputStream)) {
        return false;
    }
    ImageInputStream iis = (ImageInputStream) source;
    iis.mark();
    // If the first two bytes are a JPEG SOI marker, it's probably
    // a JPEG file.  If they aren't, it definitely isn't a JPEG file.
    int byte1 = iis.read();
    int byte2 = iis.read();
    iis.reset();
    if ((byte1 == 0xFF) && (byte2 == JPEG.SOI)) {
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JPEGImageReaderSpi.java

示例3: getThumbnail

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
BufferedImage getThumbnail(ImageInputStream iis,
                           JPEGImageReader reader)
    throws IOException {
    iis.mark();
    iis.seek(streamPos);
    // read the palette
    byte [] palette = new byte [PALETTE_SIZE];
    float palettePart = ((float) PALETTE_SIZE) / getLength();
    readByteBuffer(iis,
                   palette,
                   reader,
                   palettePart,
                   0.0F);
    DataBufferByte buffer = new DataBufferByte(thumbWidth*thumbHeight);
    readByteBuffer(iis,
                   buffer.getData(),
                   reader,
                   1.0F-palettePart,
                   palettePart);
    iis.read();
    iis.reset();

    IndexColorModel cm = new IndexColorModel(8,
                                             256,
                                             palette,
                                             0,
                                             false);
    SampleModel sm = cm.createCompatibleSampleModel(thumbWidth,
                                                    thumbHeight);
    WritableRaster raster =
        Raster.createWritableRaster(sm, buffer, null);
    return new BufferedImage(cm,
                             raster,
                             false,
                             null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:JFIFMarkerSegment.java

示例4: 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 {
         byte[] sig = new byte[4];
         stream.read(sig);
         return sig[0]=='S' && sig[1]=='I' && sig[2]=='M' && sig[3]=='P';
    } finally {
        stream.reset();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:SIMPImageReaderSpi.java

示例5: bufferFromStream

import javax.imageio.stream.ImageInputStream; //导入方法依赖的package包/类
private ByteBuffer bufferFromStream(ImageInputStream stream) throws IOException {
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  final byte[] buf = new byte[8192];
  int n;
  while (0 < (n = stream.read(buf))) {
    bos.write(buf, 0, n);
  }
  return ByteBuffer.wrap(bos.toByteArray());
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:10,代码来源:TurboJpegImageReader.java


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