本文整理匯總了Java中com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder方法的典型用法代碼示例。如果您正苦於以下問題:Java JPEGCodec.createJPEGDecoder方法的具體用法?Java JPEGCodec.createJPEGDecoder怎麽用?Java JPEGCodec.createJPEGDecoder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.image.codec.jpeg.JPEGCodec
的用法示例。
在下文中一共展示了JPEGCodec.createJPEGDecoder方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseJPGImage
import com.sun.image.codec.jpeg.JPEGCodec; //導入方法依賴的package包/類
public void parseJPGImage() { // read the embedded jpeg image
try {
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(stream);
image = decoder.decodeAsBufferedImage();
int motionLevel = motionDetector.enqueueImage(image);
plugin.setMotionLevel(motionLevel);
} catch (Exception e) {
e.printStackTrace();
disconnect();
}
}
示例2: decodeJPEG
import com.sun.image.codec.jpeg.JPEGCodec; //導入方法依賴的package包/類
/**
* Decode a buffer of data into a Raster with the specified location.
*
* @param data buffer contain an interchange or abbreviated datastream.
* @param decodeParam decoding parameters; may be null unless the
* data buffer contains an abbreviated datastream in which case
* it may not be null or an error will occur.
* @param colorConvert whether to perform color conversion; in this
* case that would be limited to YCbCr-to-RGB.
* @param minX the X position of the returned Raster.
* @param minY the Y position of the returned Raster.
*/
private static final Raster decodeJPEG(byte[] data,
JPEGDecodeParam decodeParam,
boolean colorConvert,
int minX,
int minY) {
// Create an InputStream from the compressed data array.
ByteArrayInputStream jpegStream = new ByteArrayInputStream(data);
// Create a decoder.
JPEGImageDecoder decoder = decodeParam == null ?
JPEGCodec.createJPEGDecoder(jpegStream) :
JPEGCodec.createJPEGDecoder(jpegStream,
decodeParam);
// Decode the compressed data into a Raster.
Raster jpegRaster;
try {
jpegRaster = colorConvert ?
decoder.decodeAsBufferedImage().getWritableTile(0, 0) :
decoder.decodeAsRaster();
} catch (IOException ioe) {
throw new RuntimeException("TIFFImage13");
}
// Translate the decoded Raster to the specified location and return.
return jpegRaster.createTranslatedChild(minX, minY);
}
示例3: load
import com.sun.image.codec.jpeg.JPEGCodec; //導入方法依賴的package包/類
static public BufferedImage load(InputStream stream)
//----------------------------------------------
{
BufferedImage image = null;
try {
JPEGImageDecoder decoder=JPEGCodec.createJPEGDecoder(stream);
image = decoder.decodeAsBufferedImage();
}
catch (Exception e) {e.printStackTrace();}
return image;
}