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


Java JPEGDecoder类代码示例

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


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

示例1: loadJpegTexture

import de.matthiasmann.jpegdecoder.JPEGDecoder; //导入依赖的package包/类
private Texture loadJpegTexture(String name) throws IOException {
    InputStream is = vfs.open(name);
    try {
        JPEGDecoder decoder = new JPEGDecoder(is);
        decoder.startDecode();
        int texWidth = decoder.getImageWidth();
        int texHeight = decoder.getImageHeight();
        int stride = 3 * texWidth;
        ByteBuffer buffer = ByteBuffer.allocateDirect(stride * texHeight);
        decoder.decode(buffer, stride, decoder.getNumMCURows(), YUVtoRGB.instance);
        buffer.flip();
        Texture texture = new Texture(texWidth, texHeight, false);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
        LwjglHelper.setupGLTextureParams();
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, texWidth, texHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer);
        return texture;
    } finally {
        is.close();
    }
}
 
开发者ID:devnewton,项目名称:jnuit,代码行数:22,代码来源:AssetsLoader.java

示例2: decodeVideoChunk

import de.matthiasmann.jpegdecoder.JPEGDecoder; //导入依赖的package包/类
private void decodeVideoChunk(SmjpegOutputBuffers outputBuffers) throws IOException {
    JPEGDecoder jpeg = new JPEGDecoder(new FileInputStream(file.getFD()));
    jpeg.startDecode();
    final ByteBuffer videoFrame = outputBuffers.getVideoFrame();
    videoFrame.rewind();
    jpeg.decode(videoFrame, outputBuffers.getVideoFrameStride(), jpeg.getNumMCURows(), outputBuffers.getYUVDecoder());
    videoFrame.rewind();
}
 
开发者ID:devnewton,项目名称:jnuit,代码行数:9,代码来源:SmjpegDecoder.java

示例3: getJpegHash

import de.matthiasmann.jpegdecoder.JPEGDecoder; //导入依赖的package包/类
public static String getJpegHash(InputStream is) throws NoSuchAlgorithmException, IOException {
	
	JPEGDecoder decoder = new JPEGDecoder(is);
    decoder.decodeHeader();
    int width = decoder.getImageWidth();
    int height = decoder.getImageHeight();
    decoder.startDecode();
    
    int stride = width*4; //4 bytes per pixel RGBA

    MessageDigest digester = MessageDigest.getInstance(HASH_ALGORITHM);
	for(int h=0; h<decoder.getNumMCURows(); h++) {
		
	    ByteBuffer bb = ByteBuffer.allocate(stride * decoder.getMCURowHeight());

	    decoder.decodeRGB(bb, stride, 1);
		
		digester.update(bb.array());
		
	}
	
	byte[] messageDigest = digester.digest();
	return new String(Hex.encode(messageDigest), Charset.forName("UTF-8"));
}
 
开发者ID:n8fr8,项目名称:JavaMediaHasher,代码行数:25,代码来源:MediaHasher.java

示例4: getJpegHash

import de.matthiasmann.jpegdecoder.JPEGDecoder; //导入依赖的package包/类
public static String getJpegHash(InputStream is) throws NoSuchAlgorithmException, IOException {
	
	
	JPEGDecoder decoder = new JPEGDecoder(is);
    decoder.decodeHeader();
    int width = decoder.getImageWidth();
    //int height = decoder.getImageHeight();
    decoder.startDecode();
    
    int stride = width*4; //4 bytes per pixel RGBA

    MessageDigest digester = MessageDigest.getInstance("SHA-1");
	
//    System.out.println("Stride: " + stride);
    
	for(int h=0; h<decoder.getNumMCURows(); h++) {
		
	    ByteBuffer bb = ByteBuffer.allocate(stride * decoder.getMCURowHeight());

	//	System.out.println("handling row: " + h);
		
	    decoder.decodeRGB(bb, stride, 1);
		
		digester.update(bb.array());
		
	}
	
	byte[] messageDigest = digester.digest();
	return new String(Hex.encode(messageDigest), Charset.forName("UTF-8"));
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:31,代码来源:MediaHasher.java


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