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


Java JPEGImageReader类代码示例

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


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

示例1: readHeader

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
/** Reads the image header.
 * Does nothing if the header has already been loaded.
 */
private void readHeader() throws IOException {
    if (image == null) {
        ImageReader r = new JPEGImageReader(getOriginatingProvider());
        Object in = getInput();
        if (in instanceof Buffer) {
            Buffer buffer = (Buffer) in;
            in=buffer.getData();
        }

        if (in instanceof byte[]) {
            r.setInput(new MemoryCacheImageInputStream(AVIBMPDIB.prependDHTSeg((byte[]) in)));
        } else if (in instanceof ImageInputStream) {
            r.setInput(AVIBMPDIB.prependDHTSeg((ImageInputStream) in));
        } else {
            r.setInput(AVIBMPDIB.prependDHTSeg((InputStream) in));
        }
        image = r.read(0);
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:23,代码来源:MJPGImageReader.java

示例2: createNativeJPEGReader

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
private static ImageReader createNativeJPEGReader() {
    return new JPEGImageReader(new CMYKJPEGImageReaderSpi());
    /*
     for (Iterator<ImageReader> i =
     ImageIO.getImageReadersByFormatName("jpeg"); i.hasNext();) {
     ImageReader r = i.next();
     if (!(r instanceof CMYKJPEGImageReader)
     && !r.getClass().getName().contains("CMYKJPEGImageReader")) {
     return r;
     }
     }
    
     return null;
     * 
     */
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:17,代码来源:CMYKJPEGImageReader.java

示例3: readHeader

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
/** Reads the image header.
 * Does nothing if the header has already been loaded.
 */
private void readHeader() throws IOException {
    if (image == null) {
        ImageReader r = new JPEGImageReader(getOriginatingProvider());
        Object in = getInput();
        /*if (in instanceof Buffer) {
            Buffer buffer = (Buffer) in;
            in=buffer.getData();
        }*/
        if (in instanceof byte[]) {
            r.setInput(new MemoryCacheImageInputStream(AVIBMPDIB.prependDHTSeg((byte[]) in)));
        } else if (in instanceof ImageInputStream) {
            r.setInput(AVIBMPDIB.prependDHTSeg((ImageInputStream) in));
        } else {
            r.setInput(AVIBMPDIB.prependDHTSeg((InputStream) in));
        }
        image = r.read(0);
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:22,代码来源:MJPGImageReader.java

示例4: getFormatName

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
/**
 * 获取图片文件格式
 * 
 * @param imageFile
 *            图片文件
 * 
 * @return 图片文件格式
 */
public static String getFormatName(File imageFile) {
	if (imageFile == null || imageFile.length() == 0) {
		return null;
	}
	try { 
		String formatName = null;
		ImageInputStream imageInputStream = ImageIO.createImageInputStream(imageFile);
		Iterator<ImageReader> iterator = ImageIO.getImageReaders(imageInputStream);
		if (!iterator.hasNext()) {
			return null;
		}
		ImageReader imageReader = iterator.next();
		if (imageReader instanceof JPEGImageReader) {
			formatName = JPEG_FORMAT_NAME;
		} else if (imageReader instanceof GIFImageReader) {
			formatName = GIF_FORMAT_NAME;
		} else if (imageReader instanceof BMPImageReader) {
			formatName = BMP_FORMAT_NAME;
		} else if (imageReader instanceof PNGImageReader) {
			formatName = PNG_FORMAT_NAME;
		}
		imageInputStream.close();
		return formatName; 
	} catch (IOException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:wangko27,项目名称:SelfSoftShop,代码行数:37,代码来源:ImageUtil.java

示例5: main

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    ImageReader gifReader = new GIFImageReader(null);
    ImageReader jpegReader = new JPEGImageReader(null);
    ImageReader pngReader = new PNGImageReader(null);

    test(gifReader, "GIF");
    test(jpegReader, "JPEG");
    test(pngReader, "PNG");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:AllowSearch.java

示例6: decode

import com.sun.imageio.plugins.jpeg.JPEGImageReader; //导入依赖的package包/类
public static DecodeResult decode(byte[] i_src) throws IOException
{
	JPEGImageReader jr=(JPEGImageReader)ImageIO.getImageReadersBySuffix("jpeg").next();
	jr.setInput(new MemoryCacheImageInputStream(new ByteArrayInputStream(i_src)));
	IIOMetadata data = jr.getImageMetadata(0);
	Element tree = (Element)data.getAsTree("javax_imageio_jpeg_image_1.0");
	Element jfif = (Element)tree.getElementsByTagName("app0JFIF").item(0);
	int xd=Integer.parseInt(jfif.getAttribute("Xdensity"));
	int yd=Integer.parseInt(jfif.getAttribute("Ydensity"));
	int unit=Integer.parseInt(jfif.getAttribute("resUnits"));
	BufferedImage b=jr.read(0);
	jr.dispose();//dispose

	//カラーモデルの分析
	SampleModel sp=b.getSampleModel();
	if(sp instanceof PixelInterleavedSampleModel){
		PixelInterleavedSampleModel ssp=(PixelInterleavedSampleModel)sp;
		int data_type=ssp.getDataType();
		int scan_stride=ssp.getScanlineStride();
		if(data_type==DataBuffer.TYPE_BYTE && scan_stride==b.getWidth()){
			DataBufferByte bb=(DataBufferByte)b.getData().getDataBuffer();
			return new DecodeResult(xd,yd,bb.getData(),b.getWidth(),b.getHeight(),unit);
		}else{
			//nothing todo
		}
	}else{
		//nothing todo
	}
	throw new NyARRuntimeException();
}
 
开发者ID:nyatla,项目名称:NyARToolkit,代码行数:31,代码来源:JpegIO.java


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