-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMJPGImageReaderSpi.java
More file actions
86 lines (78 loc) · 3 KB
/
MJPGImageReaderSpi.java
File metadata and controls
86 lines (78 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* @(#)MJPGImageReaderSpi.java
*
* Copyright (c) 2010-2011 Werner Randelshofer, Immensee, 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.
*/
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
/**
* ImageIO service provider interface for images in the Motion JPEG (MJPG)
* format.
* <p>
* The reader described by this class can read Motion JPEG files with omitted
* Huffmann table.
* <p>
* For more information see:
* Microsoft Windows Bitmap Format.
* Multimedia Technical Note: JPEG DIB Format.
* (c) 1993 Microsoft Corporation. All rights reserved.
* <a href="http://www.fileformat.info/format/bmp/spec/b7c72ebab8064da48ae5ed0c053c67a4/BMPDIB.TXT">BMPDIB.txt</a>
*
* @author Werner Randelshofer
* @version $Id: MJPGImageReaderSpi.java 144 2012-01-12 22:34:04Z werner $
*/
public class MJPGImageReaderSpi extends ImageReaderSpi {
public MJPGImageReaderSpi() {
super("Werner Randelshofer",//vendor name
"1.0",//version
new String[]{"MJPG"},//names
new String[]{"mjpg"},//suffixes,
new String[]{"image/mjpg"},// MIMETypes,
"org.monte.media.jmf.renderer.video.MJPGImageReader",// readerClassName,
new Class[]{ImageInputStream.class,InputStream.class,byte[].class/*,javax.media.Buffer.class*/},// inputTypes,
null,// writerSpiNames,
false,// supportsStandardStreamMetadataFormat,
null,// nativeStreamMetadataFormatName,
null,// nativeStreamMetadataFormatClassName,
null,// extraStreamMetadataFormatNames,
null,// extraStreamMetadataFormatClassNames,
false,// supportsStandardImageMetadataFormat,
null,// nativeImageMetadataFormatName,
null,// nativeImageMetadataFormatClassName,
null,// extraImageMetadataFormatNames,
null// extraImageMetadataFormatClassNames
);
}
@Override
public boolean canDecodeInput(Object source) throws IOException {
if (source instanceof ImageInputStream) {
ImageInputStream in = (ImageInputStream) source;
in.mark();
// Check if file starts with a JFIF SOI magic (0xffd8=-40)
if (in.readShort() != -40) {
in.reset();
return false;
}
in.reset();
return true;
}
return false;
}
@Override
public ImageReader createReaderInstance(Object extension) throws IOException {
return new MJPGImageReader(this);
}
@Override
public String getDescription(Locale locale) {
return "MJPG Image Reader";
}
}