本文整理汇总了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();
}
}
示例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();
}
示例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"));
}
示例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"));
}