Restructure Java classes into their own package
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@358 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/java/README b/java/README
index 0146ed3..87d3181 100644
--- a/java/README
+++ b/java/README
@@ -3,9 +3,9 @@
TurboJPEG/OSS can optionally be built with a Java Native Interface wrapper,
which allows the TurboJPEG/OSS dynamic library to be loaded and used directly
-from Java applications. The Java front end for this is defined in
-TurboJPEG.java, which should be located in the same directory as this README
-file. TurboJPEG.java is licensed under a BSD-style license, so it can be
+from Java applications. The Java front end for this is defined in several
+classes located under org/libjpegturbo/turbojpeg. The source code for these
+Java classes is licensed under a BSD-style license, so the files can be
incorporated directly into both open source and proprietary projects without
restriction.
@@ -13,7 +13,7 @@
README file, demonstrates how to use the TurboJPEG/OSS Java front end to
compress and decompress JPEG images in memory.
- javac *.java
+ javac TJExample.java
builds .class files for both the front end and example code.
diff --git a/java/TJ.h b/java/TJ.h
deleted file mode 100644
index 2527117..0000000
--- a/java/TJ.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class TJ */
-
-#ifndef _Included_TJ
-#define _Included_TJ
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef TJ_SAMP444
-#define TJ_SAMP444 0L
-#undef TJ_SAMP422
-#define TJ_SAMP422 1L
-#undef TJ_SAMP420
-#define TJ_SAMP420 2L
-#undef TJ_GRAYSCALE
-#define TJ_GRAYSCALE 3L
-#undef TJ_BGR
-#define TJ_BGR 1L
-#undef TJ_BOTTOMUP
-#define TJ_BOTTOMUP 2L
-#undef TJ_FORCEMMX
-#define TJ_FORCEMMX 8L
-#undef TJ_FORCESSE
-#define TJ_FORCESSE 16L
-#undef TJ_FORCESSE2
-#define TJ_FORCESSE2 32L
-#undef TJ_ALPHAFIRST
-#define TJ_ALPHAFIRST 64L
-#undef TJ_FORCESSE3
-#define TJ_FORCESSE3 128L
-#undef TJ_FASTUPSAMPLE
-#define TJ_FASTUPSAMPLE 256L
-#undef TJ_YUV
-#define TJ_YUV 512L
-/*
- * Class: TJ
- * Method: bufSize
- * Signature: (II)J
- */
-JNIEXPORT jlong JNICALL Java_TJ_bufSize
- (JNIEnv *, jclass, jint, jint);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/java/TJCompressor.h b/java/TJCompressor.h
deleted file mode 100644
index 15e659f..0000000
--- a/java/TJCompressor.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class TJCompressor */
-
-#ifndef _Included_TJCompressor
-#define _Included_TJCompressor
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: TJCompressor
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_TJCompressor_init
- (JNIEnv *, jobject);
-
-/*
- * Class: TJCompressor
- * Method: destroy
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_TJCompressor_destroy
- (JNIEnv *, jobject);
-
-/*
- * Class: TJCompressor
- * Method: compress
- * Signature: ([BIIII[BIII)J
- */
-JNIEXPORT jlong JNICALL Java_TJCompressor_compress
- (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/java/TJDecompressor.h b/java/TJDecompressor.h
deleted file mode 100644
index 4b61ac9..0000000
--- a/java/TJDecompressor.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class TJDecompressor */
-
-#ifndef _Included_TJDecompressor
-#define _Included_TJDecompressor
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: TJDecompressor
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_TJDecompressor_init
- (JNIEnv *, jobject);
-
-/*
- * Class: TJDecompressor
- * Method: destroy
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_TJDecompressor_destroy
- (JNIEnv *, jobject);
-
-/*
- * Class: TJDecompressor
- * Method: decompressHeader
- * Signature: ([BJ)LTJHeaderInfo;
- */
-JNIEXPORT jobject JNICALL Java_TJDecompressor_decompressHeader
- (JNIEnv *, jobject, jbyteArray, jlong);
-
-/*
- * Class: TJDecompressor
- * Method: decompress
- * Signature: ([BJ[BIIIII)V
- */
-JNIEXPORT void JNICALL Java_TJDecompressor_decompress
- (JNIEnv *, jobject, jbyteArray, jlong, jbyteArray, jint, jint, jint, jint, jint);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/java/TJExample.java b/java/TJExample.java
index 991b8eb..f6c2e43 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -32,6 +32,7 @@
*/
import java.io.*;
+import org.libjpegturbo.turbojpeg.*;
public class TJExample {
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
new file mode 100644
index 0000000..2d4d89d
--- /dev/null
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C)2011 D. R. Commander. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.libjpegturbo.turbojpeg;
+
+final public class TJ {
+
+ // Subsampling options
+ final public static int
+ SAMP444 = 0,
+ SAMP422 = 1,
+ SAMP420 = 2,
+ GRAYSCALE = 3;
+
+ // Flags
+ final public static int
+ BGR = 1,
+ BOTTOMUP = 2,
+ FORCEMMX = 8,
+ FORCESSE = 16,
+ FORCESSE2 = 32,
+ ALPHAFIRST = 64,
+ FORCESSE3 = 128,
+ FASTUPSAMPLE = 256,
+ YUV = 512;
+
+ public native final static long bufSize(int width, int height);
+};
diff --git a/java/TurboJPEG.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
similarity index 60%
copy from java/TurboJPEG.java
copy to java/org/libjpegturbo/turbojpeg/TJCompressor.java
index 0d08edc..67b70b0 100644
--- a/java/TurboJPEG.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -26,35 +26,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-final class TJ {
+package org.libjpegturbo.turbojpeg;
- // Subsampling options
- final static int
- SAMP444 = 0,
- SAMP422 = 1,
- SAMP420 = 2,
- GRAYSCALE = 3;
+public class TJCompressor {
- // Flags
- final static int
- BGR = 1,
- BOTTOMUP = 2,
- FORCEMMX = 8,
- FORCESSE = 16,
- FORCESSE2 = 32,
- ALPHAFIRST = 64,
- FORCESSE3 = 128,
- FASTUPSAMPLE = 256,
- YUV = 512;
+ public TJCompressor() throws Exception {
+ init();
+ }
- public native final static long bufSize(int width, int height);
-};
-
-class TJCompressor {
-
- TJCompressor() throws Exception {init();}
-
- public void close() throws Exception {destroy();}
+ public void close() throws Exception {
+ destroy();
+ }
protected void finalize() throws Throwable {
try {
@@ -79,45 +61,5 @@
System.loadLibrary("turbojpeg");
}
- private long handle=0;
-};
-
-class TJHeaderInfo {
- int subsamp=-1;
- int width=-1;
- int height=-1;
-};
-
-class TJDecompressor {
-
- TJDecompressor() throws Exception {init();}
-
- public void close() throws Exception {destroy();}
-
- protected void finalize() throws Throwable {
- try {
- close();
- } catch(Exception e) {
- }
- finally {
- super.finalize();
- }
- };
-
- private native void init() throws Exception;
-
- private native void destroy() throws Exception;
-
- public native TJHeaderInfo decompressHeader(byte [] srcbuf, long size)
- throws Exception;
-
- public native void decompress(byte [] srcbuf, long size, byte [] dstbuf,
- int width, int pitch, int height, int pixelsize, int flags)
- throws Exception;
-
- static {
- System.loadLibrary("turbojpeg");
- }
-
- private long handle=0;
+ private long handle = 0;
};
diff --git a/java/TurboJPEG.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
similarity index 61%
rename from java/TurboJPEG.java
rename to java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index 0d08edc..6408d58 100644
--- a/java/TurboJPEG.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -26,73 +26,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-final class TJ {
+package org.libjpegturbo.turbojpeg;
- // Subsampling options
- final static int
- SAMP444 = 0,
- SAMP422 = 1,
- SAMP420 = 2,
- GRAYSCALE = 3;
+public class TJDecompressor {
- // Flags
- final static int
- BGR = 1,
- BOTTOMUP = 2,
- FORCEMMX = 8,
- FORCESSE = 16,
- FORCESSE2 = 32,
- ALPHAFIRST = 64,
- FORCESSE3 = 128,
- FASTUPSAMPLE = 256,
- YUV = 512;
-
- public native final static long bufSize(int width, int height);
-};
-
-class TJCompressor {
-
- TJCompressor() throws Exception {init();}
-
- public void close() throws Exception {destroy();}
-
- protected void finalize() throws Throwable {
- try {
- close();
- } catch(Exception e) {
- }
- finally {
- super.finalize();
- }
- };
-
- private native void init() throws Exception;
-
- private native void destroy() throws Exception;
-
- // JPEG size in bytes is returned
- public native long compress(byte [] srcbuf, int width, int pitch,
- int height, int pixelsize, byte [] dstbuf, int jpegsubsamp, int jpegqual,
- int flags) throws Exception;
-
- static {
- System.loadLibrary("turbojpeg");
+ public TJDecompressor() throws Exception {
+ init();
}
- private long handle=0;
-};
-
-class TJHeaderInfo {
- int subsamp=-1;
- int width=-1;
- int height=-1;
-};
-
-class TJDecompressor {
-
- TJDecompressor() throws Exception {init();}
-
- public void close() throws Exception {destroy();}
+ public void close() throws Exception {
+ destroy();
+ }
protected void finalize() throws Throwable {
try {
@@ -119,5 +63,5 @@
System.loadLibrary("turbojpeg");
}
- private long handle=0;
+ private long handle = 0;
};
diff --git a/java/org/libjpegturbo/turbojpeg/TJHeaderInfo.java b/java/org/libjpegturbo/turbojpeg/TJHeaderInfo.java
new file mode 100644
index 0000000..e4ee59f
--- /dev/null
+++ b/java/org/libjpegturbo/turbojpeg/TJHeaderInfo.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C)2011 D. R. Commander. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.libjpegturbo.turbojpeg;
+
+public class TJHeaderInfo {
+ public int subsamp = -1;
+ public int width = -1;
+ public int height = -1;
+};
diff --git a/java/org_libjpegturbo_turbojpeg_TJ.h b/java/org_libjpegturbo_turbojpeg_TJ.h
new file mode 100644
index 0000000..6c0cf39
--- /dev/null
+++ b/java/org_libjpegturbo_turbojpeg_TJ.h
@@ -0,0 +1,47 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_libjpegturbo_turbojpeg_TJ */
+
+#ifndef _Included_org_libjpegturbo_turbojpeg_TJ
+#define _Included_org_libjpegturbo_turbojpeg_TJ
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef org_libjpegturbo_turbojpeg_TJ_SAMP444
+#define org_libjpegturbo_turbojpeg_TJ_SAMP444 0L
+#undef org_libjpegturbo_turbojpeg_TJ_SAMP422
+#define org_libjpegturbo_turbojpeg_TJ_SAMP422 1L
+#undef org_libjpegturbo_turbojpeg_TJ_SAMP420
+#define org_libjpegturbo_turbojpeg_TJ_SAMP420 2L
+#undef org_libjpegturbo_turbojpeg_TJ_GRAYSCALE
+#define org_libjpegturbo_turbojpeg_TJ_GRAYSCALE 3L
+#undef org_libjpegturbo_turbojpeg_TJ_BGR
+#define org_libjpegturbo_turbojpeg_TJ_BGR 1L
+#undef org_libjpegturbo_turbojpeg_TJ_BOTTOMUP
+#define org_libjpegturbo_turbojpeg_TJ_BOTTOMUP 2L
+#undef org_libjpegturbo_turbojpeg_TJ_FORCEMMX
+#define org_libjpegturbo_turbojpeg_TJ_FORCEMMX 8L
+#undef org_libjpegturbo_turbojpeg_TJ_FORCESSE
+#define org_libjpegturbo_turbojpeg_TJ_FORCESSE 16L
+#undef org_libjpegturbo_turbojpeg_TJ_FORCESSE2
+#define org_libjpegturbo_turbojpeg_TJ_FORCESSE2 32L
+#undef org_libjpegturbo_turbojpeg_TJ_ALPHAFIRST
+#define org_libjpegturbo_turbojpeg_TJ_ALPHAFIRST 64L
+#undef org_libjpegturbo_turbojpeg_TJ_FORCESSE3
+#define org_libjpegturbo_turbojpeg_TJ_FORCESSE3 128L
+#undef org_libjpegturbo_turbojpeg_TJ_FASTUPSAMPLE
+#define org_libjpegturbo_turbojpeg_TJ_FASTUPSAMPLE 256L
+#undef org_libjpegturbo_turbojpeg_TJ_YUV
+#define org_libjpegturbo_turbojpeg_TJ_YUV 512L
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJ
+ * Method: bufSize
+ * Signature: (II)J
+ */
+JNIEXPORT jlong JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
+ (JNIEnv *, jclass, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/java/org_libjpegturbo_turbojpeg_TJCompressor.h b/java/org_libjpegturbo_turbojpeg_TJCompressor.h
new file mode 100644
index 0000000..090929c
--- /dev/null
+++ b/java/org_libjpegturbo_turbojpeg_TJCompressor.h
@@ -0,0 +1,37 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_libjpegturbo_turbojpeg_TJCompressor */
+
+#ifndef _Included_org_libjpegturbo_turbojpeg_TJCompressor
+#define _Included_org_libjpegturbo_turbojpeg_TJCompressor
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJCompressor
+ * Method: init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_init
+ (JNIEnv *, jobject);
+
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJCompressor
+ * Method: destroy
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy
+ (JNIEnv *, jobject);
+
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJCompressor
+ * Method: compress
+ * Signature: ([BIIII[BIII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress
+ (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h
new file mode 100644
index 0000000..ad75327
--- /dev/null
+++ b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h
@@ -0,0 +1,45 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_libjpegturbo_turbojpeg_TJDecompressor */
+
+#ifndef _Included_org_libjpegturbo_turbojpeg_TJDecompressor
+#define _Included_org_libjpegturbo_turbojpeg_TJDecompressor
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method: init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_init
+ (JNIEnv *, jobject);
+
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method: destroy
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy
+ (JNIEnv *, jobject);
+
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method: decompressHeader
+ * Signature: ([BJ)Lorg/libjpegturbo/turbojpeg/TJHeaderInfo;
+ */
+JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressHeader
+ (JNIEnv *, jobject, jbyteArray, jlong);
+
+/*
+ * Class: org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method: decompress
+ * Signature: ([BJ[BIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
+ (JNIEnv *, jobject, jbyteArray, jlong, jbyteArray, jint, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif