30 * release 6 of the free JPEG software from the Independent JPEG Group.
31 */
32 package sun.awt.image;
33
34 import java.util.Vector;
35 import java.util.Hashtable;
36 import java.io.InputStream;
37 import java.io.IOException;
38 import java.awt.image.*;
39
40 /**
41 * JPEG Image converter
42 *
43 * @author Jim Graham
44 */
45 public class JPEGImageDecoder extends ImageDecoder {
46 private static ColorModel RGBcolormodel;
47 private static ColorModel ARGBcolormodel;
48 private static ColorModel Graycolormodel;
49
50 private static final Class InputStreamClass = InputStream.class;
51 private static native void initIDs(Class InputStreamClass);
52
53 private ColorModel colormodel;
54
55 static {
56 java.security.AccessController.doPrivileged(
57 new java.security.PrivilegedAction<Void>() {
58 public Void run() {
59 System.loadLibrary("jpeg");
60 return null;
61 }
62 });
63 initIDs(InputStreamClass);
64 RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
65 ARGBcolormodel = ColorModel.getRGBdefault();
66 byte g[] = new byte[256];
67 for (int i = 0; i < 256; i++) {
68 g[i] = (byte) i;
69 }
70 Graycolormodel = new IndexColorModel(8, 256, g, g, g);
71 }
72
73 private native void readImage(InputStream is, byte buf[])
74 throws ImageFormatException, IOException;
75
76 Hashtable props = new Hashtable();
77
78 public JPEGImageDecoder(InputStreamImageSource src, InputStream is) {
79 super(src, is);
80 }
81
82 /**
83 * An error has occurred. Throw an exception.
84 */
85 private static void error(String s1) throws ImageFormatException {
86 throw new ImageFormatException(s1);
87 }
88
89 public boolean sendHeaderInfo(int width, int height,
90 boolean gray, boolean hasalpha,
91 boolean multipass)
92 {
93 setDimensions(width, height);
94
95 setProperties(props);
96 if (gray) {
|
30 * release 6 of the free JPEG software from the Independent JPEG Group.
31 */
32 package sun.awt.image;
33
34 import java.util.Vector;
35 import java.util.Hashtable;
36 import java.io.InputStream;
37 import java.io.IOException;
38 import java.awt.image.*;
39
40 /**
41 * JPEG Image converter
42 *
43 * @author Jim Graham
44 */
45 public class JPEGImageDecoder extends ImageDecoder {
46 private static ColorModel RGBcolormodel;
47 private static ColorModel ARGBcolormodel;
48 private static ColorModel Graycolormodel;
49
50 private static final Class<?> InputStreamClass = InputStream.class;
51 private static native void initIDs(Class<?> InputStreamClass);
52
53 private ColorModel colormodel;
54
55 static {
56 java.security.AccessController.doPrivileged(
57 new java.security.PrivilegedAction<Void>() {
58 public Void run() {
59 System.loadLibrary("jpeg");
60 return null;
61 }
62 });
63 initIDs(InputStreamClass);
64 RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
65 ARGBcolormodel = ColorModel.getRGBdefault();
66 byte g[] = new byte[256];
67 for (int i = 0; i < 256; i++) {
68 g[i] = (byte) i;
69 }
70 Graycolormodel = new IndexColorModel(8, 256, g, g, g);
71 }
72
73 private native void readImage(InputStream is, byte buf[])
74 throws ImageFormatException, IOException;
75
76 Hashtable<String, Object> props = new Hashtable<>();
77
78 public JPEGImageDecoder(InputStreamImageSource src, InputStream is) {
79 super(src, is);
80 }
81
82 /**
83 * An error has occurred. Throw an exception.
84 */
85 private static void error(String s1) throws ImageFormatException {
86 throw new ImageFormatException(s1);
87 }
88
89 public boolean sendHeaderInfo(int width, int height,
90 boolean gray, boolean hasalpha,
91 boolean multipass)
92 {
93 setDimensions(width, height);
94
95 setProperties(props);
96 if (gray) {
|