Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * @(#)  
  * Copyright (c) 2010-2011 Werner Randelshofer, Goldau, Switzerland.
  * All rights reserved.
  * You may not use, copy or modify this file, except in compliance with the
  * license agreement you entered into with Werner Randelshofer.
  * For details see accompanying license terms.
ImageIO service provider interface for images in the Motion JPEG (MJPG) format.

The reader described by this class can read Motion JPEG files with omitted Huffmann table.

For more information see: Microsoft Windows Bitmap Format. Multimedia Technical Note: JPEG DIB Format. (c) 1993 Microsoft Corporation. All rights reserved. BMPDIB.txt

Werner Randelshofer
$Id: 299 2013-01-03 07:40:18Z werner $
public class MJPGImageReaderSpi extends ImageReaderSpi {
    public MJPGImageReaderSpi() {
        super("Werner Randelshofer",//vendor name
                new String[]{"MJPG"},//names
                new String[]{"mjpg"},//suffixes,
                new String[]{"image/mjpg"},// MIMETypes,
                "",// readerClassName,
                new Class[]{ImageInputStream.class,InputStream.class,byte[].class/*,*/},// inputTypes,
                null,// writerSpiNames,
                false,// supportsStandardStreamMetadataFormat,
                null,// nativeStreamMetadataFormatName,
                null,// nativeStreamMetadataFormatClassName,
                null,// extraStreamMetadataFormatNames,
                null,// extraStreamMetadataFormatClassNames,
                false,// supportsStandardImageMetadataFormat,
                null,// nativeImageMetadataFormatName,
                null,// nativeImageMetadataFormatClassName,
                null,// extraImageMetadataFormatNames,
                null// extraImageMetadataFormatClassNames
    public boolean canDecodeInput(Object sourcethrows IOException {
        if (source instanceof ImageInputStream) {
            ImageInputStream in = (ImageInputStreamsource;
            // Check if file starts with a JFIF SOI magic (0xffd8=-40)
            if (in.readShort() != -40) {
                return false;
            return true;
        return false;
    public ImageReader createReaderInstance(Object extensionthrows IOException {
        return new MJPGImageReader(this);
    public String getDescription(Locale locale) {
        return "MJPG Image Reader";
New to GrepCode? Check out our FAQ X