Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2007-07-31 10:14:32 +0400
committerjfrijters <jfrijters>2007-07-31 10:14:32 +0400
commita5caf1ece04fd340a20c2f884a0fc332cff82b8f (patch)
tree12f07e156240ea7746f8562d7260bbb1f0c1875b /openjdk/com
parenta066ffd44b3997004bb66e938da348f5ff2aa6cb (diff)
Integrated OpenJDK javax.imageio package (excluding the jpeg support, because OpenJDK uses native code for that).
Diffstat (limited to 'openjdk/com')
-rw-r--r--openjdk/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java112
-rw-r--r--openjdk/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java118
2 files changed, 230 insertions, 0 deletions
diff --git a/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java b/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
new file mode 100644
index 00000000..5ead2ab7
--- /dev/null
+++ b/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.imageio.plugins.jpeg;
+
+import java.util.Locale;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ServiceRegistry;
+import java.io.IOException;
+import javax.imageio.ImageReader;
+import javax.imageio.IIOException;
+
+public class JPEGImageReaderSpi extends ImageReaderSpi {
+
+ private static String [] writerSpiNames =
+ {"com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi"};
+
+ private boolean registered = false;
+
+ public JPEGImageReaderSpi() {
+ super(JPEG.vendor,
+ JPEG.version,
+ JPEG.names,
+ JPEG.suffixes,
+ JPEG.MIMETypes,
+ "com.sun.imageio.plugins.jpeg.JPEGImageReader",
+ STANDARD_INPUT_TYPE,
+ writerSpiNames,
+ true,
+ JPEG.nativeStreamMetadataFormatName,
+ JPEG.nativeStreamMetadataFormatClassName,
+ null, null,
+ true,
+ JPEG.nativeImageMetadataFormatName,
+ JPEG.nativeImageMetadataFormatClassName,
+ null, null
+ );
+ }
+
+ public void onRegistration(ServiceRegistry registry,
+ Class<?> category) {
+ if (registered) {
+ return;
+ }
+ /*
+ try {
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.LoadLibraryAction("jpeg"));
+ // Stuff it all into one lib for first pass
+ //java.security.AccessController.doPrivileged(
+ //new sun.security.action.LoadLibraryAction("imageioIJG"));
+ } catch (Throwable e) { // Fail on any Throwable
+ // if it can't be loaded, deregister and return
+ registry.deregisterServiceProvider(this);
+ return;
+ }
+ */
+
+ registered = true;
+ }
+
+ public String getDescription(Locale locale) {
+ return "Standard JPEG Image Reader (not implemented)";
+ }
+
+ public boolean canDecodeInput(Object source) throws IOException {
+ if (!(source instanceof ImageInputStream)) {
+ return false;
+ }
+ ImageInputStream iis = (ImageInputStream) source;
+ iis.mark();
+ // If the first two bytes are a JPEG SOI marker, it's probably
+ // a JPEG file. If they aren't, it definitely isn't a JPEG file.
+ int byte1 = iis.read();
+ int byte2 = iis.read();
+ iis.reset();
+ if ((byte1 == 0xFF) && (byte2 == JPEG.SOI)) {
+ return true;
+ }
+ return false;
+ }
+
+ public ImageReader createReaderInstance(Object extension)
+ throws IIOException {
+ throw new Error("Not implemented");
+ }
+
+}
diff --git a/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java b/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
new file mode 100644
index 00000000..b8c086ff
--- /dev/null
+++ b/openjdk/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.imageio.plugins.jpeg;
+
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.spi.ServiceRegistry;
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.ImageWriter;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.IIOException;
+
+import java.awt.image.ColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.SampleModel;
+import java.util.Locale;
+
+public class JPEGImageWriterSpi extends ImageWriterSpi {
+
+ private static String [] readerSpiNames =
+ {"com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi"};
+
+ private boolean registered = false;
+
+ public JPEGImageWriterSpi() {
+ super(JPEG.vendor,
+ JPEG.version,
+ JPEG.names,
+ JPEG.suffixes,
+ JPEG.MIMETypes,
+ "com.sun.imageio.plugins.jpeg.JPEGImageWriter",
+ STANDARD_OUTPUT_TYPE,
+ readerSpiNames,
+ true,
+ JPEG.nativeStreamMetadataFormatName,
+ JPEG.nativeStreamMetadataFormatClassName,
+ null, null,
+ true,
+ JPEG.nativeImageMetadataFormatName,
+ JPEG.nativeImageMetadataFormatClassName,
+ null, null
+ );
+ }
+
+ public String getDescription(Locale locale) {
+ return "Standard JPEG Image Writer (not implemented)";
+ }
+
+ public void onRegistration(ServiceRegistry registry,
+ Class<?> category) {
+ if (registered) {
+ return;
+ }
+ /*
+ try {
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.LoadLibraryAction("jpeg"));
+ } catch (Throwable e) { // Fail on any Throwable
+ // if it can't be loaded, deregister and return
+ registry.deregisterServiceProvider(this);
+ return;
+ }
+ */
+
+ registered = true;
+ }
+
+ public boolean isFormatLossless() {
+ return false;
+ }
+
+ public boolean canEncodeImage(ImageTypeSpecifier type) {
+ SampleModel sampleModel = type.getSampleModel();
+
+ // Find the maximum bit depth across all channels
+ int[] sampleSize = sampleModel.getSampleSize();
+ int bitDepth = sampleSize[0];
+ for (int i = 1; i < sampleSize.length; i++) {
+ if (sampleSize[i] > bitDepth) {
+ bitDepth = sampleSize[i];
+ }
+ }
+
+ // 4450894: Ensure bitDepth is between 1 and 8
+ if (bitDepth < 1 || bitDepth > 8) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public ImageWriter createWriterInstance(Object extension)
+ throws IIOException {
+ throw new Error("Not implemented");
+ }
+}