aboutsummaryrefslogtreecommitdiff
path: root/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'java/org')
-rw-r--r--java/org/.svn/all-wcprops5
-rw-r--r--java/org/.svn/entries31
-rw-r--r--java/org/libjpegturbo/.svn/all-wcprops5
-rw-r--r--java/org/libjpegturbo/.svn/entries31
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/all-wcprops53
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/entries300
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJ.java.svn-base322
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJCompressor.java.svn-base460
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJDecompressor.java.svn-base510
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.in.svn-base35
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.svn-base35
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJScalingFactor.java.svn-base98
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransform.java.svn-base182
-rw-r--r--java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransformer.java.svn-base158
14 files changed, 0 insertions, 2225 deletions
diff --git a/java/org/.svn/all-wcprops b/java/org/.svn/all-wcprops
deleted file mode 100644
index 2cf48c7..0000000
--- a/java/org/.svn/all-wcprops
+++ /dev/null
@@ -1,5 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 50
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org
-END
diff --git a/java/org/.svn/entries b/java/org/.svn/entries
deleted file mode 100644
index 78e5851..0000000
--- a/java/org/.svn/entries
+++ /dev/null
@@ -1,31 +0,0 @@
-10
-
-dir
-677
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk/java/org
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo
-
-
-
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3789f03b-4d11-0410-bbf8-ca57d06f2519
-
-libjpegturbo
-dir
-
diff --git a/java/org/libjpegturbo/.svn/all-wcprops b/java/org/libjpegturbo/.svn/all-wcprops
deleted file mode 100644
index 9c320df..0000000
--- a/java/org/libjpegturbo/.svn/all-wcprops
+++ /dev/null
@@ -1,5 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org/libjpegturbo
-END
diff --git a/java/org/libjpegturbo/.svn/entries b/java/org/libjpegturbo/.svn/entries
deleted file mode 100644
index 53f9ee3..0000000
--- a/java/org/libjpegturbo/.svn/entries
+++ /dev/null
@@ -1,31 +0,0 @@
-10
-
-dir
-677
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk/java/org/libjpegturbo
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo
-
-
-
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3789f03b-4d11-0410-bbf8-ca57d06f2519
-
-turbojpeg
-dir
-
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/all-wcprops b/java/org/libjpegturbo/turbojpeg/.svn/all-wcprops
deleted file mode 100644
index 4675726..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/all-wcprops
+++ /dev/null
@@ -1,53 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org/libjpegturbo/turbojpeg
-END
-TJTransformer.java
-K 25
-svn:wc:ra_dav:version-url
-V 92
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org/libjpegturbo/turbojpeg/TJTransformer.java
-END
-TJDecompressor.java
-K 25
-svn:wc:ra_dav:version-url
-V 93
-/svnroot/libjpeg-turbo/!svn/ver/557/trunk/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
-END
-TJLoader.java
-K 25
-svn:wc:ra_dav:version-url
-V 87
-/svnroot/libjpeg-turbo/!svn/ver/557/trunk/java/org/libjpegturbo/turbojpeg/TJLoader.java
-END
-TJLoader.java.in
-K 25
-svn:wc:ra_dav:version-url
-V 90
-/svnroot/libjpeg-turbo/!svn/ver/557/trunk/java/org/libjpegturbo/turbojpeg/TJLoader.java.in
-END
-TJTransform.java
-K 25
-svn:wc:ra_dav:version-url
-V 90
-/svnroot/libjpeg-turbo/!svn/ver/556/trunk/java/org/libjpegturbo/turbojpeg/TJTransform.java
-END
-TJCompressor.java
-K 25
-svn:wc:ra_dav:version-url
-V 91
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org/libjpegturbo/turbojpeg/TJCompressor.java
-END
-TJ.java
-K 25
-svn:wc:ra_dav:version-url
-V 81
-/svnroot/libjpeg-turbo/!svn/ver/668/trunk/java/org/libjpegturbo/turbojpeg/TJ.java
-END
-TJScalingFactor.java
-K 25
-svn:wc:ra_dav:version-url
-V 94
-/svnroot/libjpeg-turbo/!svn/ver/560/trunk/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java
-END
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/entries b/java/org/libjpegturbo/turbojpeg/.svn/entries
deleted file mode 100644
index 1449d64..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/entries
+++ /dev/null
@@ -1,300 +0,0 @@
-10
-
-dir
-677
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk/java/org/libjpegturbo/turbojpeg
-https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo
-
-
-
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3789f03b-4d11-0410-bbf8-ca57d06f2519
-
-TJTransformer.java
-file
-
-
-
-
-2011-08-08T15:47:01.955056Z
-c42ce425b22ae1521304636c77cd916e
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6677
-
-TJDecompressor.java
-file
-
-
-
-
-2011-08-08T15:47:01.955056Z
-82f2386dd0a05608805000416cb5dd85
-2011-04-02T02:09:03.005969Z
-557
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-20624
-
-TJLoader.java
-file
-
-
-
-
-2011-08-08T15:47:01.955056Z
-b56142efea7228451fb2ef709272b4a2
-2011-04-02T02:09:03.005969Z
-557
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1706
-
-TJLoader.java.in
-file
-
-
-
-
-2011-08-08T15:47:01.955056Z
-a115f898e607c2545fdcf7d64196c874
-2011-04-02T02:09:03.005969Z
-557
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1717
-
-TJTransform.java
-file
-
-
-
-
-2011-08-08T15:47:01.965056Z
-9364417040e29ed364abf6f09f9bca3d
-2011-04-01T20:31:03.974822Z
-556
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6706
-
-TJCompressor.java
-file
-
-
-
-
-2011-08-08T15:47:01.965056Z
-f7181d1692d522a320545164e1f2bc09
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-17863
-
-TJ.java
-file
-
-
-
-
-2011-08-08T15:47:01.965056Z
-ee2b7c81e8df5d124d46b3be3295482c
-2011-07-12T03:17:23.655236Z
-668
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11233
-
-TJScalingFactor.java
-file
-
-
-
-
-2011-08-08T15:47:01.965056Z
-09cc9c58be8aacb04bc4cbc30ea46902
-2011-04-02T03:43:12.360898Z
-560
-dcommander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3188
-
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJ.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJ.java.svn-base
deleted file mode 100644
index cd22ee0..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJ.java.svn-base
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * 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;
-
-/**
- * TurboJPEG utility class (cannot be instantiated)
- */
-final public class TJ {
-
-
- /**
- * The number of chrominance subsampling options
- */
- final public static int NUMSAMP = 5;
- /**
- * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG
- * or YUV image will contain one chrominance component for every pixel in the
- * source image.
- */
- final public static int SAMP_444 = 0;
- /**
- * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x1 block of pixels in the source image.
- */
- final public static int SAMP_422 = 1;
- /**
- * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x2 block of pixels in the source image.
- */
- final public static int SAMP_420 = 2;
- /**
- * Grayscale. The JPEG or YUV image will contain no chrominance components.
- */
- final public static int SAMP_GRAY = 3;
- /**
- * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x2 block of pixels in the source image.
- */
- final public static int SAMP_440 = 4;
-
-
- /**
- * Returns the MCU block width for the given level of chrominance
- * subsampling.
- *
- * @param subsamp the level of chrominance subsampling (one of
- * <code>SAMP_*</code>)
- *
- * @return the MCU block width for the given level of chrominance subsampling
- */
- public static int getMCUWidth(int subsamp) throws Exception {
- if(subsamp < 0 || subsamp >= NUMSAMP)
- throw new Exception("Invalid subsampling type");
- return mcuWidth[subsamp];
- }
-
- final private static int mcuWidth[] = {
- 8, 16, 16, 8, 8
- };
-
-
- /**
- * Returns the MCU block height for the given level of chrominance
- * subsampling.
- *
- * @param subsamp the level of chrominance subsampling (one of
- * <code>SAMP_*</code>)
- *
- * @return the MCU block height for the given level of chrominance
- * subsampling
- */
- public static int getMCUHeight(int subsamp) throws Exception {
- if(subsamp < 0 || subsamp >= NUMSAMP)
- throw new Exception("Invalid subsampling type");
- return mcuHeight[subsamp];
- }
-
- final private static int mcuHeight[] = {
- 8, 8, 16, 8, 16
- };
-
-
- /**
- * The number of pixel formats
- */
- final public static int NUMPF = 7;
- /**
- * RGB pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel.
- */
- final public static int PF_RGB = 0;
- /**
- * BGR pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel.
- */
- final public static int PF_BGR = 1;
- /**
- * RGBX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel.
- */
- final public static int PF_RGBX = 2;
- /**
- * BGRX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel.
- */
- final public static int PF_BGRX = 3;
- /**
- * XBGR pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from highest to lowest byte
- * address within each pixel.
- */
- final public static int PF_XBGR = 4;
- /**
- * XRGB pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from highest to lowest byte
- * address within each pixel.
- */
- final public static int PF_XRGB = 5;
- /**
- * Grayscale pixel format. Each 1-byte pixel represents a luminance
- * (brightness) level from 0 to 255.
- */
- final public static int PF_GRAY = 6;
-
-
- /**
- * Returns the pixel size (in bytes) of the given pixel format.
- *
- * @param pixelFormat the pixel format (one of <code>PF_*</code>)
- *
- * @return the pixel size (in bytes) of the given pixel format
- */
- public static int getPixelSize(int pixelFormat) throws Exception {
- if(pixelFormat < 0 || pixelFormat >= NUMPF)
- throw new Exception("Invalid pixel format");
- return pixelSize[pixelFormat];
- }
-
- final private static int pixelSize[] = {
- 3, 3, 4, 4, 4, 4, 1
- };
-
-
- /**
- * For the given pixel format, returns the number of bytes that the red
- * component is offset from the start of the pixel. For instance, if a pixel
- * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
- * then the red component will be
- * <code>pixel[TJ.getRedOffset(TJ.PF_BGRX)]</code>.
- *
- * @param pixelFormat the pixel format (one of <code>PF_*</code>)
- *
- * @return the red offset for the given pixel format
- */
- public static int getRedOffset(int pixelFormat) throws Exception {
- if(pixelFormat < 0 || pixelFormat >= NUMPF)
- throw new Exception("Invalid pixel format");
- return redOffset[pixelFormat];
- }
-
- final private static int redOffset[] = {
- 0, 2, 0, 2, 3, 1, 0
- };
-
-
- /**
- * For the given pixel format, returns the number of bytes that the green
- * component is offset from the start of the pixel. For instance, if a pixel
- * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
- * then the green component will be
- * <code>pixel[TJ.getGreenOffset(TJ.PF_BGRX)]</code>.
- *
- * @param pixelFormat the pixel format (one of <code>PF_*</code>)
- *
- * @return the green offset for the given pixel format
- */
- public static int getGreenOffset(int pixelFormat) throws Exception {
- if(pixelFormat < 0 || pixelFormat >= NUMPF)
- throw new Exception("Invalid pixel format");
- return greenOffset[pixelFormat];
- }
-
- final private static int greenOffset[] = {
- 1, 1, 1, 1, 2, 2, 0
- };
-
-
- /**
- * For the given pixel format, returns the number of bytes that the blue
- * component is offset from the start of the pixel. For instance, if a pixel
- * of format <code>TJ.PF_BGRX</code> is stored in <code>char pixel[]</code>,
- * then the blue component will be
- * <code>pixel[TJ.getBlueOffset(TJ.PF_BGRX)]</code>.
- *
- * @param pixelFormat the pixel format (one of <code>PF_*</code>)
- *
- * @return the blue offset for the given pixel format
- */
- public static int getBlueOffset(int pixelFormat) throws Exception {
- if(pixelFormat < 0 || pixelFormat >= NUMPF)
- throw new Exception("Invalid pixel format");
- return blueOffset[pixelFormat];
- }
-
- final private static int blueOffset[] = {
- 2, 0, 2, 0, 1, 3, 0
- };
-
-
- /**
- * The uncompressed source/destination image is stored in bottom-up (Windows,
- * OpenGL) order, not top-down (X11) order.
- */
- final public static int FLAG_BOTTOMUP = 2;
- /**
- * Turn off CPU auto-detection and force TurboJPEG to use MMX code
- * (IPP and 32-bit libjpeg-turbo versions only.)
- */
- final public static int FLAG_FORCEMMX = 8;
- /**
- * Turn off CPU auto-detection and force TurboJPEG to use SSE code
- * (32-bit IPP and 32-bit libjpeg-turbo versions only.)
- */
- final public static int FLAG_FORCESSE = 16;
- /**
- * Turn off CPU auto-detection and force TurboJPEG to use SSE2 code
- * (32-bit IPP and 32-bit libjpeg-turbo versions only.)
- */
- final public static int FLAG_FORCESSE2 = 32;
- /**
- * Turn off CPU auto-detection and force TurboJPEG to use SSE3 code
- *(64-bit IPP version only.)
- */
- final public static int FLAG_FORCESSE3 = 128;
- /**
- * Use fast, inaccurate chrominance upsampling routines in the JPEG
- * decompressor (libjpeg and libjpeg-turbo versions only.)
- */
- final public static int FLAG_FASTUPSAMPLE = 256;
-
-
- /**
- * Returns the maximum size of the buffer (in bytes) required to hold a JPEG
- * image with the given width and height, and level of chrominance
- * subsampling.
- *
- * @param width the width (in pixels) of the JPEG image
- *
- * @param height the height (in pixels) of the JPEG image
- *
- * @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (one of {@link TJ TJ.SAMP_*})
- *
- * @return the maximum size of the buffer (in bytes) required to hold a JPEG
- * image with the given width and height, and level of chrominance
- * subsampling
- */
- public native static int bufSize(int width, int height, int jpegSubsamp)
- throws Exception;
-
- /**
- * Returns the size of the buffer (in bytes) required to hold a YUV planar
- * image with the given width, height, and level of chrominance subsampling.
- *
- * @param width the width (in pixels) of the YUV image
- *
- * @param height the height (in pixels) of the YUV image
- *
- * @param subsamp the level of chrominance subsampling used in the YUV
- * image (one of {@link TJ TJ.SAMP_*})
- *
- * @return the size of the buffer (in bytes) required to hold a YUV planar
- * image with the given width, height, and level of chrominance subsampling
- */
- public native static int bufSizeYUV(int width, int height,
- int subsamp)
- throws Exception;
-
- /**
- * Returns a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports.
- *
- * @return a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports
- */
- public native static TJScalingFactor[] getScalingFactors()
- throws Exception;
-
- static {
- TJLoader.load();
- }
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJCompressor.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJCompressor.java.svn-base
deleted file mode 100644
index 1029139..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJCompressor.java.svn-base
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * 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;
-
-import java.awt.image.*;
-import java.nio.*;
-
-/**
- * TurboJPEG compressor
- */
-public class TJCompressor {
-
- private final static String NO_ASSOC_ERROR =
- "No source image is associated with this instance";
-
- /**
- * Create a TurboJPEG compressor instance.
- */
- public TJCompressor() throws Exception {
- init();
- }
-
- /**
- * Create a TurboJPEG compressor instance and associate the uncompressed
- * source image stored in <code>srcImage</code> with the newly-created
- * instance.
- *
- * @param srcImage see {@link #setSourceImage} for description
- *
- * @param width see {@link #setSourceImage} for description
- *
- * @param pitch see {@link #setSourceImage} for description
- *
- * @param height see {@link #setSourceImage} for description
- *
- * @param pixelFormat see {@link #setSourceImage} for description
- */
- public TJCompressor(byte[] srcImage, int width, int pitch, int height,
- int pixelFormat) throws Exception {
- setSourceImage(srcImage, width, pitch, height, pixelFormat);
- }
-
- /**
- * Associate an uncompressed source image with this compressor instance.
- *
- * @param srcImage image buffer containing RGB or grayscale pixels to be
- * compressed
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line of the source image. Normally, this should be
- * <code>width * TJ.pixelSize(pixelFormat)</code> if the source image is
- * unpadded, but you can use this parameter to, for instance, specify that
- * the scanlines in the source image are padded to 4-byte boundaries, as is
- * the case for Windows bitmaps. You can also be clever and use this
- * parameter to skip lines, etc. Setting this parameter to 0 is the
- * equivalent of setting it to <code>width *
- * TJ.pixelSize(pixelFormat)</code>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (one of
- * {@link TJ TJ.PF_*})
- */
- public void setSourceImage(byte[] srcImage, int width, int pitch,
- int height, int pixelFormat) throws Exception {
- if(handle == 0) init();
- if(srcImage == null || width < 1 || height < 1 || pitch < 0
- || pixelFormat < 0 || pixelFormat >= TJ.NUMPF)
- throw new Exception("Invalid argument in setSourceImage()");
- srcBuf = srcImage;
- srcWidth = width;
- if(pitch == 0) srcPitch = width * TJ.getPixelSize(pixelFormat);
- else srcPitch = pitch;
- srcHeight = height;
- srcPixelFormat = pixelFormat;
- }
-
- /**
- * Set the level of chrominance subsampling for subsequent compress/encode
- * operations.
- *
- * @param newSubsamp the new level of chrominance subsampling (one of
- * {@link TJ TJ.SAMP_*})
- */
- public void setSubsamp(int newSubsamp) throws Exception {
- if(newSubsamp < 0 || newSubsamp >= TJ.NUMSAMP)
- throw new Exception("Invalid argument in setSubsamp()");
- subsamp = newSubsamp;
- }
-
- /**
- * Set the JPEG image quality level for subsequent compress operations.
- *
- * @param quality the new JPEG image quality level (1 to 100, 1 = worst,
- * 100 = best)
- */
- public void setJPEGQuality(int quality) throws Exception {
- if(quality < 1 || quality > 100)
- throw new Exception("Invalid argument in setJPEGQuality()");
- jpegQuality = quality;
- }
-
- /**
- * Compress the uncompressed source image associated with this compressor
- * instance and output a JPEG image to the given destination buffer.
- *
- * @param dstBuf buffer which will receive the JPEG image. Use
- * {@link TJ#bufSize} to determine the maximum size for this buffer based on
- * the image width and height.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void compress(byte[] dstBuf, int flags) throws Exception {
- if(dstBuf == null || flags < 0)
- throw new Exception("Invalid argument in compress()");
- if(srcBuf == null) throw new Exception(NO_ASSOC_ERROR);
- if(jpegQuality < 0) throw new Exception("JPEG Quality not set");
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- compressedSize = compress(srcBuf, srcWidth, srcPitch,
- srcHeight, srcPixelFormat, dstBuf, subsamp, jpegQuality, flags);
- }
-
- /**
- * Compress the uncompressed source image associated with this compressor
- * instance and return a buffer containing a JPEG image.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing a JPEG image. The length of this buffer will
- * not be equal to the size of the JPEG image. Use {@link
- * #getCompressedSize} to obtain the size of the JPEG image.
- */
- public byte[] compress(int flags) throws Exception {
- if(srcWidth < 1 || srcHeight < 1)
- throw new Exception(NO_ASSOC_ERROR);
- byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
- compress(buf, flags);
- return buf;
- }
-
- /**
- * Compress the uncompressed source image stored in <code>srcImage</code>
- * and output a JPEG image to the given destination buffer.
- *
- * @param srcImage a <code>BufferedImage</code> instance containing RGB or
- * grayscale pixels to be compressed
- *
- * @param dstBuf buffer which will receive the JPEG image. Use
- * {@link TJ#bufSize} to determine the maximum size for this buffer based on
- * the image width and height.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void compress(BufferedImage srcImage, byte[] dstBuf, int flags)
- throws Exception {
- if(srcImage == null || dstBuf == null || flags < 0)
- throw new Exception("Invalid argument in compress()");
- int width = srcImage.getWidth();
- int height = srcImage.getHeight();
- int pixelFormat; boolean intPixels = false;
- if(byteOrder == null)
- byteOrder = ByteOrder.nativeOrder();
- switch(srcImage.getType()) {
- case BufferedImage.TYPE_3BYTE_BGR:
- pixelFormat = TJ.PF_BGR; break;
- case BufferedImage.TYPE_BYTE_GRAY:
- pixelFormat = TJ.PF_GRAY; break;
- case BufferedImage.TYPE_INT_BGR:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XBGR;
- else
- pixelFormat = TJ.PF_RGBX;
- intPixels = true; break;
- case BufferedImage.TYPE_INT_RGB:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XRGB;
- else
- pixelFormat = TJ.PF_BGRX;
- intPixels = true; break;
- default:
- throw new Exception("Unsupported BufferedImage format");
- }
- WritableRaster wr = srcImage.getRaster();
- if(jpegQuality < 0) throw new Exception("JPEG Quality not set");
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- if(intPixels) {
- SinglePixelPackedSampleModel sm =
- (SinglePixelPackedSampleModel)srcImage.getSampleModel();
- int pitch = sm.getScanlineStride();
- DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
- int[] buf = db.getData();
- compressedSize = compress(buf, width, pitch, height, pixelFormat, dstBuf,
- subsamp, jpegQuality, flags);
- }
- else {
- ComponentSampleModel sm =
- (ComponentSampleModel)srcImage.getSampleModel();
- int pixelSize = sm.getPixelStride();
- if(pixelSize != TJ.getPixelSize(pixelFormat))
- throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage");
- int pitch = sm.getScanlineStride();
- DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
- byte[] buf = db.getData();
- compressedSize = compress(buf, width, pitch, height, pixelFormat, dstBuf,
- subsamp, jpegQuality, flags);
- }
- }
-
- /**
- * Compress the uncompressed source image stored in <code>srcImage</code>
- * and return a buffer containing a JPEG image.
- *
- * @param srcImage a <code>BufferedImage</code> instance containing RGB or
- * grayscale pixels to be compressed
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing a JPEG image. The length of this buffer will
- * not be equal to the size of the JPEG image. Use {@link
- * #getCompressedSize} to obtain the size of the JPEG image.
- */
- public byte[] compress(BufferedImage srcImage, int flags) throws Exception {
- int width = srcImage.getWidth();
- int height = srcImage.getHeight();
- byte[] buf = new byte[TJ.bufSize(width, height, subsamp)];
- compress(srcImage, buf, flags);
- return buf;
- }
-
- /**
- * Encode the uncompressed source image associated with this compressor
- * instance and output a YUV planar image to the given destination buffer.
- * This method uses the accelerated color conversion routines in
- * TurboJPEG's underlying codec to produce a planar YUV image that is
- * suitable for direct video display. Specifically, if the chrominance
- * components are subsampled along the horizontal dimension, then the width
- * of the luminance plane is padded to 2 in the output image (same goes for
- * the height of the luminance plane, if the chrominance components are
- * subsampled along the vertical dimension.) Also, each line of each plane
- * in the output image is padded to 4 bytes. Although this will work with
- * any subsampling option, it is really only useful in combination with
- * {@link TJ#SAMP_420}, which produces an image compatible with the I420 (AKA
- * "YUV420P") format.
- *
- * @param dstBuf buffer which will receive the YUV planar image. Use
- * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer
- * based on the image width, height, and level of chrominance subsampling.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void encodeYUV(byte[] dstBuf, int flags) throws Exception {
- if(dstBuf == null || flags < 0)
- throw new Exception("Invalid argument in compress()");
- if(srcBuf == null) throw new Exception(NO_ASSOC_ERROR);
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight,
- srcPixelFormat, dstBuf, subsamp, flags);
- compressedSize = TJ.bufSizeYUV(srcWidth, srcHeight, subsamp);
- }
-
- /**
- * Encode the uncompressed source image associated with this compressor
- * instance and return a buffer containing a YUV planar image. See
- * {@link #encodeYUV(byte[], int)} for more detail.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing a YUV planar image
- */
- public byte[] encodeYUV(int flags) throws Exception {
- if(srcWidth < 1 || srcHeight < 1)
- throw new Exception(NO_ASSOC_ERROR);
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- byte[] buf = new byte[TJ.bufSizeYUV(srcWidth, srcHeight, subsamp)];
- encodeYUV(buf, flags);
- return buf;
- }
-
- /**
- * Encode the uncompressed source image stored in <code>srcImage</code>
- * and output a YUV planar image to the given destination buffer. See
- * {@link #encodeYUV(byte[], int)} for more detail.
- *
- * @param srcImage a <code>BufferedImage</code> instance containing RGB or
- * grayscale pixels to be encoded
- *
- * @param dstBuf buffer which will receive the YUV planar image. Use
- * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer
- * based on the image width, height, and level of chrominance subsampling.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void encodeYUV(BufferedImage srcImage, byte[] dstBuf, int flags)
- throws Exception {
- if(srcImage == null || dstBuf == null || flags < 0)
- throw new Exception("Invalid argument in encodeYUV()");
- int width = srcImage.getWidth();
- int height = srcImage.getHeight();
- int pixelFormat; boolean intPixels = false;
- if(byteOrder == null)
- byteOrder = ByteOrder.nativeOrder();
- switch(srcImage.getType()) {
- case BufferedImage.TYPE_3BYTE_BGR:
- pixelFormat = TJ.PF_BGR; break;
- case BufferedImage.TYPE_BYTE_GRAY:
- pixelFormat = TJ.PF_GRAY; break;
- case BufferedImage.TYPE_INT_BGR:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XBGR;
- else
- pixelFormat = TJ.PF_RGBX;
- intPixels = true; break;
- case BufferedImage.TYPE_INT_RGB:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XRGB;
- else
- pixelFormat = TJ.PF_BGRX;
- intPixels = true; break;
- default:
- throw new Exception("Unsupported BufferedImage format");
- }
- WritableRaster wr = srcImage.getRaster();
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- if(intPixels) {
- SinglePixelPackedSampleModel sm =
- (SinglePixelPackedSampleModel)srcImage.getSampleModel();
- int pitch = sm.getScanlineStride();
- DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
- int[] buf = db.getData();
- encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, subsamp,
- flags);
- }
- else {
- ComponentSampleModel sm =
- (ComponentSampleModel)srcImage.getSampleModel();
- int pixelSize = sm.getPixelStride();
- if(pixelSize != TJ.getPixelSize(pixelFormat))
- throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage");
- int pitch = sm.getScanlineStride();
- DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
- byte[] buf = db.getData();
- encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, subsamp,
- flags);
- }
- compressedSize = TJ.bufSizeYUV(width, height, subsamp);
- }
-
- /**
- * Encode the uncompressed source image stored in <code>srcImage</code>
- * and return a buffer containing a YUV planar image. See
- * {@link #encodeYUV(byte[], int)} for more detail.
- *
- * @param srcImage a <code>BufferedImage</code> instance containing RGB or
- * grayscale pixels to be encoded
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing a YUV planar image
- */
- public byte[] encodeYUV(BufferedImage srcImage, int flags)
- throws Exception {
- if(subsamp < 0) throw new Exception("Subsampling level not set");
- int width = srcImage.getWidth();
- int height = srcImage.getHeight();
- byte[] buf = new byte[TJ.bufSizeYUV(width, height, subsamp)];
- encodeYUV(srcImage, buf, flags);
- return buf;
- }
-
- /**
- * Returns the size of the image (in bytes) generated by the most recent
- * compress/encode operation.
- *
- * @return the size of the image (in bytes) generated by the most recent
- * compress/encode operation
- */
- public int getCompressedSize() {
- return compressedSize;
- }
-
- /**
- * Free the native structures associated with this compressor instance.
- */
- 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
- private native int compress(byte[] srcBuf, int width, int pitch,
- int height, int pixelFormat, byte[] dstbuf, int jpegSubsamp, int jpegQual,
- int flags) throws Exception;
-
- private native int compress(int[] srcBuf, int width, int pitch,
- int height, int pixelFormat, byte[] dstbuf, int jpegSubsamp, int jpegQual,
- int flags) throws Exception;
-
- private native void encodeYUV(byte[] srcBuf, int width, int pitch,
- int height, int pixelFormat, byte[] dstbuf, int subsamp, int flags)
- throws Exception;
-
- private native void encodeYUV(int[] srcBuf, int width, int pitch,
- int height, int pixelFormat, byte[] dstbuf, int subsamp, int flags)
- throws Exception;
-
- static {
- TJLoader.load();
- }
-
- private long handle = 0;
- private byte[] srcBuf = null;
- private int srcWidth = 0;
- private int srcHeight = 0;
- private int srcPitch = 0;
- private int srcPixelFormat = -1;
- private int subsamp = -1;
- private int jpegQuality = -1;
- private int compressedSize = 0;
- private ByteOrder byteOrder = null;
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJDecompressor.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJDecompressor.java.svn-base
deleted file mode 100644
index b247847..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJDecompressor.java.svn-base
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * 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;
-
-import java.awt.image.*;
-import java.nio.*;
-
-/**
- * TurboJPEG decompressor
- */
-public class TJDecompressor {
-
- private final static String NO_ASSOC_ERROR =
- "No JPEG image is associated with this instance";
-
- /**
- * Create a TurboJPEG decompresssor instance.
- */
- public TJDecompressor() throws Exception {
- init();
- }
-
- /**
- * Create a TurboJPEG decompressor instance and associate the JPEG image
- * stored in <code>jpegImage</code> with the newly-created instance.
- *
- * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
- * be the length of the array)
- */
- public TJDecompressor(byte[] jpegImage) throws Exception {
- init();
- setJPEGImage(jpegImage, jpegImage.length);
- }
-
- /**
- * Create a TurboJPEG decompressor instance and associate the JPEG image
- * of length <code>imageSize</code> bytes stored in <code>jpegImage</code>
- * with the newly-created instance.
- *
- * @param jpegImage JPEG image buffer
- *
- * @param imageSize size of the JPEG image (in bytes)
- */
- public TJDecompressor(byte[] jpegImage, int imageSize) throws Exception {
- init();
- setJPEGImage(jpegImage, imageSize);
- }
-
- /**
- * Associate the JPEG image of length <code>imageSize</code> bytes stored in
- * <code>jpegImage</code> with this decompressor instance. This image will
- * be used as the source image for subsequent decompress operations.
- *
- * @param jpegImage JPEG image buffer
- *
- * @param imageSize size of the JPEG image (in bytes)
- */
- public void setJPEGImage(byte[] jpegImage, int imageSize) throws Exception {
- if(jpegImage == null || imageSize < 1)
- throw new Exception("Invalid argument in setJPEGImage()");
- jpegBuf = jpegImage;
- jpegBufSize = imageSize;
- decompressHeader(jpegBuf, jpegBufSize);
- }
-
- /**
- * Returns the width of the JPEG image associated with this decompressor
- * instance.
- *
- * @return the width of the JPEG image associated with this decompressor
- * instance
- */
- public int getWidth() throws Exception {
- if(jpegWidth < 1) throw new Exception(NO_ASSOC_ERROR);
- return jpegWidth;
- }
-
- /**
- * Returns the height of the JPEG image associated with this decompressor
- * instance.
- *
- * @return the height of the JPEG image associated with this decompressor
- * instance
- */
- public int getHeight() throws Exception {
- if(jpegHeight < 1) throw new Exception(NO_ASSOC_ERROR);
- return jpegHeight;
- }
-
- /**
- * Returns the level of chrominance subsampling used in the JPEG image
- * associated with this decompressor instance.
- *
- * @return the level of chrominance subsampling used in the JPEG image
- * associated with this decompressor instance
- */
- public int getSubsamp() throws Exception {
- if(jpegSubsamp < 0) throw new Exception(NO_ASSOC_ERROR);
- if(jpegSubsamp >= TJ.NUMSAMP)
- throw new Exception("JPEG header information is invalid");
- return jpegSubsamp;
- }
-
- /**
- * Returns the JPEG image buffer associated with this decompressor instance.
- *
- * @return the JPEG image buffer associated with this decompressor instance
- */
- public byte[] getJPEGBuf() throws Exception {
- if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
- return jpegBuf;
- }
-
- /**
- * Returns the size of the JPEG image (in bytes) associated with this
- * decompressor instance.
- *
- * @return the size of the JPEG image (in bytes) associated with this
- * decompressor instance
- */
- public int getJPEGSize() throws Exception {
- if(jpegBufSize < 1) throw new Exception(NO_ASSOC_ERROR);
- return jpegBufSize;
- }
-
-
- /**
- * Returns the width of the largest scaled down image that the TurboJPEG
- * decompressor can generate without exceeding the desired image width and
- * height.
- *
- * @param desiredWidth desired width (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the width of the JPEG image
- * (in other words, the width will not be considered when determining the
- * scaled image size.)
- *
- * @param desiredHeight desired height (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the height of the JPEG
- * image (in other words, the height will not be considered when determining
- * the scaled image size.)
- *
- * @return the width of the largest scaled down image that the TurboJPEG
- * decompressor can generate without exceeding the desired image width and
- * height
- */
- public int getScaledWidth(int desiredWidth, int desiredHeight)
- throws Exception {
- if(jpegWidth < 1 || jpegHeight < 1)
- throw new Exception(NO_ASSOC_ERROR);
- if(desiredWidth < 0 || desiredHeight < 0)
- throw new Exception("Invalid argument in getScaledWidth()");
- TJScalingFactor sf[] = TJ.getScalingFactors();
- if(desiredWidth == 0) desiredWidth = jpegWidth;
- if(desiredHeight == 0) desiredHeight = jpegHeight;
- int scaledWidth = jpegWidth, scaledHeight = jpegHeight;
- for(int i = 0; i < sf.length; i++) {
- scaledWidth = sf[i].getScaled(jpegWidth);
- scaledHeight = sf[i].getScaled(jpegHeight);
- if(scaledWidth <= desiredWidth && scaledHeight <= desiredHeight)
- break;
- }
- if(scaledWidth > desiredWidth || scaledHeight > desiredHeight)
- throw new Exception("Could not scale down to desired image dimensions");
- return scaledWidth;
- }
-
- /**
- * Returns the height of the largest scaled down image that the TurboJPEG
- * decompressor can generate without exceeding the desired image width and
- * height.
- *
- * @param desiredWidth desired width (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the width of the JPEG image
- * (in other words, the width will not be considered when determining the
- * scaled image size.)
- *
- * @param desiredHeight desired height (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the height of the JPEG
- * image (in other words, the height will not be considered when determining
- * the scaled image size.)
- *
- * @return the height of the largest scaled down image that the TurboJPEG
- * decompressor can generate without exceeding the desired image width and
- * height
- */
- public int getScaledHeight(int desiredWidth, int desiredHeight)
- throws Exception {
- if(jpegWidth < 1 || jpegHeight < 1)
- throw new Exception(NO_ASSOC_ERROR);
- if(desiredWidth < 0 || desiredHeight < 0)
- throw new Exception("Invalid argument in getScaledHeight()");
- TJScalingFactor sf[] = TJ.getScalingFactors();
- if(desiredWidth == 0) desiredWidth = jpegWidth;
- if(desiredHeight == 0) desiredHeight = jpegHeight;
- int scaledWidth = jpegWidth, scaledHeight = jpegHeight;
- for(int i = 0; i < sf.length; i++) {
- scaledWidth = sf[i].getScaled(jpegWidth);
- scaledHeight = sf[i].getScaled(jpegHeight);
- if(scaledWidth <= desiredWidth && scaledHeight <= desiredHeight)
- break;
- }
- if(scaledWidth > desiredWidth || scaledHeight > desiredHeight)
- throw new Exception("Could not scale down to desired image dimensions");
- return scaledHeight;
- }
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and output a decompressed image to the given destination buffer.
- *
- * @param dstBuf buffer which will receive the decompressed image. This
- * buffer should normally be <code>pitch * scaledHeight</code> bytes in size,
- * where <code>scaledHeight</code> can be determined by calling <code>
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
- * </code> with one of the scaling factors returned from {@link
- * TJ#getScalingFactors} or by calling {@link #getScaledHeight}.
- *
- * @param desiredWidth desired width (in pixels) of the decompressed image.
- * If the desired image dimensions are smaller than the dimensions of the
- * JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG
- * decompressor to generate the largest possible image that will fit within
- * the desired dimensions. Setting this to 0 is the same as setting it to
- * the width of the JPEG image (in other words, the width will not be
- * considered when determining the scaled image size.)
- *
- * @param pitch bytes per line of the destination image. Normally, this
- * should be set to <code>scaledWidth * TJ.pixelSize(pixelFormat)</code> if
- * the decompressed image is unpadded, but you can use this to, for instance,
- * pad each line of the decompressed image to a 4-byte boundary. NOTE:
- * <code>scaledWidth</code> can be determined by calling <code>
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
- * </code> or by calling {@link #getScaledWidth}. Setting this parameter to
- * 0 is the equivalent of setting it to <code>scaledWidth *
- * TJ.pixelSize(pixelFormat)</code>.
- *
- * @param desiredHeight desired height (in pixels) of the decompressed image.
- * If the desired image dimensions are smaller than the dimensions of the
- * JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG
- * decompressor to generate the largest possible image that will fit within
- * the desired dimensions. Setting this to 0 is the same as setting it to
- * the height of the JPEG image (in other words, the height will not be
- * considered when determining the scaled image size.)
- *
- * @param pixelFormat pixel format of the decompressed image (one of
- * {@link TJ TJ.PF_*})
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void decompress(byte[] dstBuf, int desiredWidth, int pitch,
- int desiredHeight, int pixelFormat, int flags) throws Exception {
- if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
- if(dstBuf == null || desiredWidth < 0 || pitch < 0 || desiredHeight < 0
- || pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
- throw new Exception("Invalid argument in decompress()");
- decompress(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pitch,
- desiredHeight, pixelFormat, flags);
- }
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and return a buffer containing the decompressed image.
- *
- * @param desiredWidth see
- * {@link #decompress(byte[], int, int, int, int, int)} for description
- *
- * @param pitch see
- * {@link #decompress(byte[], int, int, int, int, int)} for description
- *
- * @param desiredHeight see
- * {@link #decompress(byte[], int, int, int, int, int)} for description
- *
- * @param pixelFormat pixel format of the decompressed image (one of
- * {@link TJ TJ.PF_*})
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing the decompressed image
- */
- public byte[] decompress(int desiredWidth, int pitch, int desiredHeight,
- int pixelFormat, int flags) throws Exception {
- if(desiredWidth < 0 || pitch < 0 || desiredHeight < 0
- || pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
- throw new Exception("Invalid argument in decompress()");
- int pixelSize = TJ.getPixelSize(pixelFormat);
- int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
- int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
- if(pitch == 0) pitch = scaledWidth * pixelSize;
- byte[] buf = new byte[pitch * scaledHeight];
- decompress(buf, desiredWidth, pitch, desiredHeight, pixelFormat, flags);
- return buf;
- }
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and output a YUV planar image to the given destination buffer.
- * This method performs JPEG decompression but leaves out the color
- * conversion step, so a planar YUV image is generated instead of an RGB
- * image. The padding of the planes in this image is the same as the images
- * generated by {@link TJCompressor#encodeYUV(byte[], int)}. Note that, if
- * the width or height of the image is not an even multiple of the MCU block
- * size (see {@link TJ#getMCUWidth} and {@link TJ#getMCUHeight}), then an
- * intermediate buffer copy will be performed within TurboJPEG.
- *
- * @param dstBuf buffer which will receive the YUV planar image. Use
- * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer
- * based on the image width, height, and level of chrominance subsampling.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void decompressToYUV(byte[] dstBuf, int flags) throws Exception {
- if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
- if(dstBuf == null || flags < 0)
- throw new Exception("Invalid argument in decompressToYUV()");
- decompressToYUV(jpegBuf, jpegBufSize, dstBuf, flags);
- }
-
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and return a buffer containing a YUV planar image. See {@link
- * #decompressToYUV(byte[], int)} for more detail.
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a buffer containing a YUV planar image
- */
- public byte[] decompressToYUV(int flags) throws Exception {
- if(flags < 0)
- throw new Exception("Invalid argument in decompressToYUV()");
- if(jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0)
- throw new Exception(NO_ASSOC_ERROR);
- if(jpegSubsamp >= TJ.NUMSAMP)
- throw new Exception("JPEG header information is invalid");
- byte[] buf = new byte[TJ.bufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp)];
- decompressToYUV(buf, flags);
- return buf;
- }
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and output a decompressed image to the given
- * <code>BufferedImage</code> instance.
- *
- * @param dstImage a <code>BufferedImage</code> instance which will receive
- * the decompressed image
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void decompress(BufferedImage dstImage, int flags) throws Exception {
- if(dstImage == null || flags < 0)
- throw new Exception("Invalid argument in decompress()");
- int desiredWidth = dstImage.getWidth();
- int desiredHeight = dstImage.getHeight();
- int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
- int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
- if(scaledWidth != desiredWidth || scaledHeight != desiredHeight)
- throw new Exception("BufferedImage dimensions do not match a scaled image size that TurboJPEG is capable of generating.");
- int pixelFormat; boolean intPixels = false;
- if(byteOrder == null)
- byteOrder = ByteOrder.nativeOrder();
- switch(dstImage.getType()) {
- case BufferedImage.TYPE_3BYTE_BGR:
- pixelFormat = TJ.PF_BGR; break;
- case BufferedImage.TYPE_BYTE_GRAY:
- pixelFormat = TJ.PF_GRAY; break;
- case BufferedImage.TYPE_INT_BGR:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XBGR;
- else
- pixelFormat = TJ.PF_RGBX;
- intPixels = true; break;
- case BufferedImage.TYPE_INT_RGB:
- if(byteOrder == ByteOrder.BIG_ENDIAN)
- pixelFormat = TJ.PF_XRGB;
- else
- pixelFormat = TJ.PF_BGRX;
- intPixels = true; break;
- default:
- throw new Exception("Unsupported BufferedImage format");
- }
- WritableRaster wr = dstImage.getRaster();
- if(intPixels) {
- SinglePixelPackedSampleModel sm =
- (SinglePixelPackedSampleModel)dstImage.getSampleModel();
- int pitch = sm.getScanlineStride();
- DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
- int[] buf = db.getData();
- if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
- decompress(jpegBuf, jpegBufSize, buf, scaledWidth, pitch, scaledHeight,
- pixelFormat, flags);
- }
- else {
- ComponentSampleModel sm =
- (ComponentSampleModel)dstImage.getSampleModel();
- int pixelSize = sm.getPixelStride();
- if(pixelSize != TJ.getPixelSize(pixelFormat))
- throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage");
- int pitch = sm.getScanlineStride();
- DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
- byte[] buf = db.getData();
- decompress(buf, scaledWidth, pitch, scaledHeight, pixelFormat, flags);
- }
- }
-
- /**
- * Decompress the JPEG source image associated with this decompressor
- * instance and return a <code>BufferedImage</code> instance containing the
- * decompressed image.
- *
- * @param desiredWidth see
- * {@link #decompress(byte[], int, int, int, int, int)} for description
- *
- * @param desiredHeight see
- * {@link #decompress(byte[], int, int, int, int, int)} for description
- *
- * @param bufferedImageType the image type of the newly-created
- * <code>BufferedImage</code> instance (for instance,
- * <code>BufferedImage.TYPE_INT_RGB</code>)
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- *
- * @return a <code>BufferedImage</code> instance containing the
- * decompressed image
- */
- public BufferedImage decompress(int desiredWidth, int desiredHeight,
- int bufferedImageType, int flags) throws Exception {
- if(desiredWidth < 0 || desiredHeight < 0 || flags < 0)
- throw new Exception("Invalid argument in decompress()");
- int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
- int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
- BufferedImage img = new BufferedImage(scaledWidth, scaledHeight,
- bufferedImageType);
- decompress(img, flags);
- return img;
- }
-
- /**
- * Free the native structures associated with this decompressor instance.
- */
- 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;
-
- private native void decompressHeader(byte[] srcBuf, int size)
- throws Exception;
-
- private native void decompress(byte[] srcBuf, int size, byte[] dstBuf,
- int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
- throws Exception;
-
- private native void decompress(byte[] srcBuf, int size, int[] dstBuf,
- int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
- throws Exception;
-
- private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
- int flags)
- throws Exception;
-
- static {
- TJLoader.load();
- }
-
- protected long handle = 0;
- protected byte[] jpegBuf = null;
- protected int jpegBufSize = 0;
- protected int jpegWidth = 0;
- protected int jpegHeight = 0;
- protected int jpegSubsamp = -1;
- private ByteOrder byteOrder = null;
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.in.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.in.svn-base
deleted file mode 100644
index 22353a5..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.in.svn-base
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 class TJLoader {
- static void load() {
- System.loadLibrary("@TURBOJPEG_DLL_NAME@");
- }
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.svn-base
deleted file mode 100644
index db77bba..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJLoader.java.svn-base
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 class TJLoader {
- static void load() {
- System.loadLibrary("turbojpeg");
- }
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJScalingFactor.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJScalingFactor.java.svn-base
deleted file mode 100644
index d71ceee..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJScalingFactor.java.svn-base
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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;
-
-/**
- * Fractional scaling factor
- */
-public class TJScalingFactor {
-
- public TJScalingFactor(int num, int denom) throws Exception {
- if(num < 1 || denom < 1)
- throw new Exception("Numerator and denominator must be >= 1");
- this.num = num;
- this.denom = denom;
- }
-
- /**
- * Returns numerator
- * @return numerator
- */
- public int getNum() {
- return num;
- }
-
- /**
- * Returns denominator
- * @return denominator
- */
- public int getDenom() {
- return denom;
- }
-
- /**
- * Returns the scaled value of <code>dimension</code>. This function
- * performs the integer equivalent of
- * <code>ceil(dimension * scalingFactor)</code>.
- * @return the scaled value of <code>dimension</code>
- */
- public int getScaled(int dimension) {
- return (dimension * num + denom - 1) / denom;
- }
-
- /**
- * Returns true or false, depending on whether this instance and
- * <code>other</code> have the same numerator and denominator.
- * @return true or false, depending on whether this instance and
- * <code>other</code> have the same numerator and denominator
- */
- public boolean equals(TJScalingFactor other) {
- return (this.num == other.num && this.denom == other.denom);
- }
-
- /**
- * Returns true or false, depending on whether this instance is equal to
- * 1/1.
- * @return true or false, depending on whether this instance is equal to
- * 1/1
- */
- public boolean isOne() {
- return (num == 1 && denom == 1);
- }
-
- /**
- * Numerator
- */
- private int num = 1;
-
- /**
- * Denominator
- */
- private int denom = 1;
-};
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransform.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransform.java.svn-base
deleted file mode 100644
index 3f4eb38..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransform.java.svn-base
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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;
-
-import java.awt.*;
-
-/**
- * Lossless transform parameters
- */
-public class TJTransform extends Rectangle {
-
- private static final long serialVersionUID = -127367705761430371L;
-
-
- /**
- * The number of lossless transform operations
- */
- final public static int NUMOP = 8;
- /**
- * Do not transform the position of the image pixels.
- */
- final public static int OP_NONE = 0;
- /**
- * Flip (mirror) image horizontally. This transform is imperfect if there
- * are any partial MCU blocks on the right edge.
- * @see #OPT_PERFECT
- */
- final public static int OP_HFLIP = 1;
- /**
- * Flip (mirror) image vertically. This transform is imperfect if there are
- * any partial MCU blocks on the bottom edge.
- * @see #OPT_PERFECT
- */
- final public static int OP_VFLIP = 2;
- /**
- * Transpose image (flip/mirror along upper left to lower right axis). This
- * transform is always perfect.
- * @see #OPT_PERFECT
- */
- final public static int OP_TRANSPOSE = 3;
- /**
- * Transverse transpose image (flip/mirror along upper right to lower left
- * axis). This transform is imperfect if there are any partial MCU blocks in
- * the image.
- * @see #OPT_PERFECT
- */
- final public static int OP_TRANSVERSE = 4;
- /**
- * Rotate image clockwise by 90 degrees. This transform is imperfect if
- * there are any partial MCU blocks on the bottom edge.
- * @see #OPT_PERFECT
- */
- final public static int OP_ROT90 = 5;
- /**
- * Rotate image 180 degrees. This transform is imperfect if there are any
- * partial MCU blocks in the image.
- * @see #OPT_PERFECT
- */
- final public static int OP_ROT180 = 6;
- /**
- * Rotate image counter-clockwise by 90 degrees. This transform is imperfect
- * if there are any partial MCU blocks on the right edge.
- * @see #OPT_PERFECT
- */
- final public static int OP_ROT270 = 7;
-
-
- /**
- * This option will cause {@link TJTransformer#transform
- * TJTransformer.transform()} to throw an exception if the transform is not
- * perfect. Lossless transforms operate on MCU blocks, whose size depends on
- * the level of chrominance subsampling used. If the image's width or height
- * is not evenly divisible by the MCU block size (see {@link TJ#getMCUWidth}
- * and {@link TJ#getMCUHeight}), then there will be partial MCU blocks on the
- * right and/or bottom edges. It is not possible to move these partial MCU
- * blocks to the top or left of the image, so any transform that would
- * require that is "imperfect." If this option is not specified, then any
- * partial MCU blocks that cannot be transformed will be left in place, which
- * will create odd-looking strips on the right or bottom edge of the image.
- */
- final public static int OPT_PERFECT = 1;
- /**
- * This option will discard any partial MCU blocks that cannot be
- * transformed.
- */
- final public static int OPT_TRIM = 2;
- /**
- * This option will enable lossless cropping.
- */
- final public static int OPT_CROP = 4;
- /**
- * This option will discard the color data in the input image and produce
- * a grayscale output image.
- */
- final public static int OPT_GRAY = 8;
-
-
- /**
- * Create a new lossless transform instance.
- */
- public TJTransform() {
- }
-
- /**
- * Create a new lossless transform instance with the given parameters.
- *
- * @param x the left boundary of the cropping region. This must be evenly
- * divisible by the MCU block width (see {@link TJ#getMCUWidth})
- *
- * @param y the upper boundary of the cropping region. This must be evenly
- * divisible by the MCU block height (see {@link TJ#getMCUHeight})
- *
- * @param w the width of the cropping region. Setting this to 0 is the
- * equivalent of setting it to the width of the source JPEG image - x.
- *
- * @param h the height of the cropping region. Setting this to 0 is the
- * equivalent of setting it to the height of the source JPEG image - y.
- *
- * @param op one of the transform operations (<code>OP_*</code>)
- *
- * @param options the bitwise OR of one or more of the transform options
- * (<code>OPT_*</code>)
- */
- public TJTransform(int x, int y, int w, int h, int op, int options)
- throws Exception {
- super(x, y, w, h);
- this.op = op; this.options = options;
- }
-
- /**
- * Create a new lossless transform instance with the given parameters.
- *
- * @param r a <code>Rectangle</code> instance which specifies the cropping
- * region. See {@link #TJTransform(int, int, int, int, int, int)} for more
- * detail.
- *
- * @param op one of the transform operations (<code>OP_*</code>)
- *
- * @param options the bitwise OR of one or more of the transform options
- * (<code>OPT_*</code>)
- */
- public TJTransform(Rectangle r, int op, int options) throws Exception {
- super(r);
- this.op = op; this.options = options;
- }
-
- /**
- * Transform operation (one of <code>OP_*</code>)
- */
- public int op = 0;
-
- /**
- * Transform options (bitwise OR of one or more of <code>OPT_*</code>)
- */
- public int options = 0;
-}
diff --git a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransformer.java.svn-base b/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransformer.java.svn-base
deleted file mode 100644
index 6c07483..0000000
--- a/java/org/libjpegturbo/turbojpeg/.svn/text-base/TJTransformer.java.svn-base
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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;
-
-/**
- * TurboJPEG lossless transformer
- */
-public class TJTransformer extends TJDecompressor {
-
- /**
- * Create a TurboJPEG lossless transformer instance.
- */
- public TJTransformer() throws Exception {
- init();
- }
-
- /**
- * Create a TurboJPEG lossless transformer instance and associate the JPEG
- * image stored in <code>jpegImage</code> with the newly-created instance.
- *
- * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
- * be the length of the array)
- */
- public TJTransformer(byte[] jpegImage) throws Exception {
- init();
- setJPEGImage(jpegImage, jpegImage.length);
- }
-
- /**
- * Create a TurboJPEG lossless transformer instance and associate the JPEG
- * image of length <code>imageSize</code> bytes stored in
- * <code>jpegImage</code> with the newly-created instance.
- *
- * @param jpegImage JPEG image buffer
- *
- * @param imageSize size of the JPEG image (in bytes)
- */
- public TJTransformer(byte[] jpegImage, int imageSize) throws Exception {
- init();
- setJPEGImage(jpegImage, imageSize);
- }
-
- /**
- * Losslessly transform the JPEG image associated with this transformer
- * instance into one or more JPEG images stored in the given destination
- * buffers. Lossless transforms work by moving the raw coefficients from one
- * JPEG image structure to another without altering the values of the
- * coefficients. While this is typically faster than decompressing the
- * image, transforming it, and re-compressing it, lossless transforms are not
- * free. Each lossless transform requires reading and Huffman decoding all
- * of the coefficients in the source image, regardless of the size of the
- * destination image. Thus, this method provides a means of generating
- * multiple transformed images from the same source or of applying multiple
- * transformations simultaneously, in order to eliminate the need to read the
- * source coefficients multiple times.
- *
- * @param dstBufs an array of image buffers. <code>dstbufs[i]</code> will
- * receive a JPEG image that has been transformed using the parameters in
- * <code>transforms[i]</code>. Use {@link TJ#bufSize} to determine the
- * maximum size for each buffer based on the cropped width and height.
- *
- * @param transforms an array of {@link TJTransform} instances, each of
- * which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public void transform(byte[][] dstBufs, TJTransform[] transforms,
- int flags) throws Exception {
- if(jpegBuf == null) throw new Exception("JPEG buffer not initialized");
- transformedSizes = transform(jpegBuf, jpegBufSize, dstBufs, transforms,
- flags);
- }
-
- /**
- * Losslessly transform the JPEG image associated with this transformer
- * instance and return an array of {@link TJDecompressor} instances, each of
- * which has a transformed JPEG image associated with it.
- *
- * @param transforms an array of {@link TJTransform} instances, each of
- * which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image
- *
- * @return an array of {@link TJDecompressor} instances, each of
- * which has a transformed JPEG image associated with it
- *
- * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
- */
- public TJDecompressor[] transform(TJTransform[] transforms, int flags)
- throws Exception {
- byte[][] dstBufs = new byte[transforms.length][];
- if(jpegWidth < 1 || jpegHeight < 1)
- throw new Exception("JPEG buffer not initialized");
- for(int i = 0; i < transforms.length; i++) {
- int w = jpegWidth, h = jpegHeight;
- if((transforms[i].options & TJTransform.OPT_CROP) != 0) {
- if(transforms[i].width != 0) w = transforms[i].width;
- if(transforms[i].height != 0) h = transforms[i].height;
- }
- dstBufs[i] = new byte[TJ.bufSize(w, h, jpegSubsamp)];
- }
- TJDecompressor[] tjd = new TJDecompressor[transforms.length];
- transform(dstBufs, transforms, flags);
- for(int i = 0; i < transforms.length; i++)
- tjd[i] = new TJDecompressor(dstBufs[i], transformedSizes[i]);
- return tjd;
- }
-
- /**
- * Returns an array containing the sizes of the transformed JPEG images from
- * the most recent call to {@link #transform transform()}.
- *
- * @return an array containing the sizes of the transformed JPEG images from
- * the most recent call to {@link #transform transform()}
- */
- public int[] getTransformedSizes() throws Exception {
- if(transformedSizes == null)
- throw new Exception("No image has been transformed yet");
- return transformedSizes;
- }
-
- private native void init() throws Exception;
-
- private native int[] transform(byte[] srcBuf, int srcSize, byte[][] dstBufs,
- TJTransform[] transforms, int flags) throws Exception;
-
- static {
- TJLoader.load();
- }
-
- private int[] transformedSizes = null;
-};