Throw idiomatic unchecked exceptions from the Java classes and JNI wrapper if there is an unrecoverable error caused by incorrect API usage (such as illegal arguments, etc.), and throw Errors if there is an unrecoverable error at the C level (such as a failed malloc() call.)
Change the behavior of the bailif0() macro in the JNI wrapper so that it doesn't throw an exception for an unexpected NULL condition. In fact, in all cases, the underlying JNI API function (such as GetFieldID(), etc.) will throw an Error on its own whenever it returns NULL, so our custom exceptions were never being thrown in that case anyhow. All we need to do is just detect the error and bail out of the C code. This also corrects a couple of formatting issues (semicolons aren't needed at the end of class definitions, and @Override should be specified for the methods we're overriding from super-classes, so the compiler can sanity-check that we're actually overriding a method and not declaring a new one.) git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1595 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -983,16 +983,13 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getMCUWidth</h4>
|
||||
<pre>public static int getMCUWidth(int subsamp)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getMCUWidth(int subsamp)</pre>
|
||||
<div class="block">Returns the MCU block width for the given level of chrominance
|
||||
subsampling.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>subsamp</code> - the level of chrominance subsampling (one of
|
||||
<code>SAMP_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the MCU block width for the given level of chrominance
|
||||
subsampling.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
subsampling.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getMCUHeight(int)">
|
||||
@@ -1001,16 +998,13 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getMCUHeight</h4>
|
||||
<pre>public static int getMCUHeight(int subsamp)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getMCUHeight(int subsamp)</pre>
|
||||
<div class="block">Returns the MCU block height for the given level of chrominance
|
||||
subsampling.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>subsamp</code> - the level of chrominance subsampling (one of
|
||||
<code>SAMP_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the MCU block height for the given level of chrominance
|
||||
subsampling.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
subsampling.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getPixelSize(int)">
|
||||
@@ -1019,13 +1013,10 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getPixelSize</h4>
|
||||
<pre>public static int getPixelSize(int pixelFormat)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getPixelSize(int pixelFormat)</pre>
|
||||
<div class="block">Returns the pixel size (in bytes) for the given pixel format.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the pixel size (in bytes) for the given pixel format.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the pixel size (in bytes) for the given pixel format.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getRedOffset(int)">
|
||||
@@ -1034,17 +1025,14 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getRedOffset</h4>
|
||||
<pre>public static int getRedOffset(int pixelFormat)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getRedOffset(int pixelFormat)</pre>
|
||||
<div class="block">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>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the red offset for the given pixel format.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the red offset for the given pixel format.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getGreenOffset(int)">
|
||||
@@ -1053,17 +1041,14 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getGreenOffset</h4>
|
||||
<pre>public static int getGreenOffset(int pixelFormat)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getGreenOffset(int pixelFormat)</pre>
|
||||
<div class="block">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>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the green offset for the given pixel format.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the green offset for the given pixel format.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getBlueOffset(int)">
|
||||
@@ -1072,17 +1057,14 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getBlueOffset</h4>
|
||||
<pre>public static int getBlueOffset(int pixelFormat)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public static int getBlueOffset(int pixelFormat)</pre>
|
||||
<div class="block">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>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the blue offset for the given pixel format.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the blue offset for the given pixel format.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="bufSize(int, int, int)">
|
||||
|
||||
@@ -563,8 +563,7 @@ public void setSourceImage(byte[] srcImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>setSubsamp</h4>
|
||||
<pre>public void setSubsamp(int newSubsamp)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public void setSubsamp(int newSubsamp)</pre>
|
||||
<div class="block">Set the level of chrominance subsampling for subsequent compress/encode
|
||||
operations. When pixels are converted from RGB to YCbCr (see
|
||||
<a href="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCbCr"><code>TJ.CS_YCbCr</code></a>) or from CMYK to YCCK (see <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCCK"><code>TJ.CS_YCCK</code></a>) as part
|
||||
@@ -582,9 +581,7 @@ public void setSourceImage(byte[] srcImage,
|
||||
destination.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>newSubsamp</code> - the level of chrominance subsampling to use in
|
||||
subsequent compress/encode oeprations (one of
|
||||
<a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>)</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="setJPEGQuality(int)">
|
||||
@@ -593,13 +590,10 @@ public void setSourceImage(byte[] srcImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>setJPEGQuality</h4>
|
||||
<pre>public void setJPEGQuality(int quality)
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public void setJPEGQuality(int quality)</pre>
|
||||
<div class="block">Set the JPEG image quality level for subsequent compress operations.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>quality</code> - the new JPEG image quality level (1 to 100, 1 = worst,
|
||||
100 = best)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
100 = best)</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="compress(byte[], int)">
|
||||
|
||||
@@ -653,14 +653,11 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getWidth</h4>
|
||||
<pre>public int getWidth()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getWidth()</pre>
|
||||
<div class="block">Returns the width of the source image (JPEG or YUV) associated with this
|
||||
decompressor instance.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the width of the source image (JPEG or YUV) associated with this
|
||||
decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getHeight()">
|
||||
@@ -669,14 +666,11 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getHeight</h4>
|
||||
<pre>public int getHeight()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getHeight()</pre>
|
||||
<div class="block">Returns the height of the source image (JPEG or YUV) associated with this
|
||||
decompressor instance.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the height of the source image (JPEG or YUV) associated with this
|
||||
decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getSubsamp()">
|
||||
@@ -685,15 +679,12 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getSubsamp</h4>
|
||||
<pre>public int getSubsamp()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getSubsamp()</pre>
|
||||
<div class="block">Returns the level of chrominance subsampling used in the source image
|
||||
(JPEG or YUV) associated with this decompressor instance. See
|
||||
<a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the level of chrominance subsampling used in the source image
|
||||
(JPEG or YUV) associated with this decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
(JPEG or YUV) associated with this decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getColorspace()">
|
||||
@@ -702,15 +693,12 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getColorspace</h4>
|
||||
<pre>public int getColorspace()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getColorspace()</pre>
|
||||
<div class="block">Returns the colorspace used in the source image (JPEG or YUV) associated
|
||||
with this decompressor instance. See <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_RGB"><code>TJ.CS_*</code></a>. If the
|
||||
source image is YUV, then this always returns <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCbCr"><code>TJ.CS_YCbCr</code></a>.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the colorspace used in the source image (JPEG or YUV) associated
|
||||
with this decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
with this decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getJPEGBuf()">
|
||||
@@ -719,12 +707,9 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getJPEGBuf</h4>
|
||||
<pre>public byte[] getJPEGBuf()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public byte[] getJPEGBuf()</pre>
|
||||
<div class="block">Returns the JPEG image buffer associated with this decompressor instance.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the JPEG image buffer associated with this decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the JPEG image buffer associated with this decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getJPEGSize()">
|
||||
@@ -733,14 +718,11 @@ public void setJPEGImage(byte[] jpegImage,
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getJPEGSize</h4>
|
||||
<pre>public int getJPEGSize()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getJPEGSize()</pre>
|
||||
<div class="block">Returns the size of the JPEG image (in bytes) associated with this
|
||||
decompressor instance.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the size of the JPEG image (in bytes) associated with this
|
||||
decompressor instance.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
decompressor instance.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getScaledWidth(int, int)">
|
||||
|
||||
@@ -192,10 +192,7 @@ extends java.lang.Object</pre>
|
||||
<li class="blockList">
|
||||
<h4>TJScalingFactor</h4>
|
||||
<pre>public TJScalingFactor(int num,
|
||||
int denom)
|
||||
throws java.lang.Exception</pre>
|
||||
<dl><dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
int denom)</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -341,14 +341,11 @@ extends <a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title=
|
||||
<ul class="blockListLast">
|
||||
<li class="blockList">
|
||||
<h4>getTransformedSizes</h4>
|
||||
<pre>public int[] getTransformedSizes()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int[] getTransformedSizes()</pre>
|
||||
<div class="block">Returns an array containing the sizes of the transformed JPEG images
|
||||
generated by the most recent transform operation.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>an array containing the sizes of the transformed JPEG images
|
||||
generated by the most recent transform operation.</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
generated by the most recent transform operation.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@@ -610,12 +610,9 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getWidth</h4>
|
||||
<pre>public int getWidth()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getWidth()</pre>
|
||||
<div class="block">Returns the width of the YUV image (or subregion.)</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the width of the YUV image (or subregion)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the width of the YUV image (or subregion)</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getHeight()">
|
||||
@@ -624,12 +621,9 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getHeight</h4>
|
||||
<pre>public int getHeight()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getHeight()</pre>
|
||||
<div class="block">Returns the height of the YUV image (or subregion.)</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the height of the YUV image (or subregion)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the height of the YUV image (or subregion)</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getPad()">
|
||||
@@ -638,13 +632,10 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getPad</h4>
|
||||
<pre>public int getPad()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getPad()</pre>
|
||||
<div class="block">Returns the line padding used in the YUV image buffer (if this image is
|
||||
stored in a unified buffer rather than separate image planes.)</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the line padding used in the YUV image buffer</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the line padding used in the YUV image buffer</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getStrides()">
|
||||
@@ -653,12 +644,9 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getStrides</h4>
|
||||
<pre>public int[] getStrides()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int[] getStrides()</pre>
|
||||
<div class="block">Returns the number of bytes per line of each plane in the YUV image.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the number of bytes per line of each plane in the YUV image</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the number of bytes per line of each plane in the YUV image</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getOffsets()">
|
||||
@@ -667,14 +655,11 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getOffsets</h4>
|
||||
<pre>public int[] getOffsets()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int[] getOffsets()</pre>
|
||||
<div class="block">Returns the offsets (in bytes) of each plane within the planes of a larger
|
||||
YUV image.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the offsets (in bytes) of each plane within the planes of a larger
|
||||
YUV image</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
YUV image</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getSubsamp()">
|
||||
@@ -683,13 +668,10 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getSubsamp</h4>
|
||||
<pre>public int getSubsamp()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public int getSubsamp()</pre>
|
||||
<div class="block">Returns the level of chrominance subsampling used in the YUV image. See
|
||||
<a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the level of chrominance subsampling used in the YUV image</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the level of chrominance subsampling used in the YUV image</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getPlanes()">
|
||||
@@ -698,13 +680,10 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getPlanes</h4>
|
||||
<pre>public byte[][] getPlanes()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public byte[][] getPlanes()</pre>
|
||||
<div class="block">Returns the YUV image planes. If the image is stored in a unified buffer,
|
||||
then all image planes will point to that buffer.</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the YUV image planes</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the YUV image planes</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getBuf()">
|
||||
@@ -713,13 +692,10 @@ extends java.lang.Object</pre>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getBuf</h4>
|
||||
<pre>public byte[] getBuf()
|
||||
throws java.lang.Exception</pre>
|
||||
<pre>public byte[] getBuf()</pre>
|
||||
<div class="block">Returns the YUV image buffer (if this image is stored in a unified
|
||||
buffer rather than separate image planes.)</div>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the YUV image buffer</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code>java.lang.Exception</code></dd></dl>
|
||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the YUV image buffer</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getSize()">
|
||||
|
||||
@@ -87,9 +87,8 @@ public final class TJ {
|
||||
* @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");
|
||||
public static int getMCUWidth(int subsamp) {
|
||||
checkSubsampling(subsamp);
|
||||
return mcuWidth[subsamp];
|
||||
}
|
||||
|
||||
@@ -108,9 +107,8 @@ public final class TJ {
|
||||
* @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");
|
||||
public static int getMCUHeight(int subsamp) {
|
||||
checkSubsampling(subsamp);
|
||||
return mcuHeight[subsamp];
|
||||
}
|
||||
|
||||
@@ -217,9 +215,8 @@ public final class TJ {
|
||||
*
|
||||
* @return the pixel size (in bytes) for the given pixel format.
|
||||
*/
|
||||
public static int getPixelSize(int pixelFormat) throws Exception {
|
||||
if (pixelFormat < 0 || pixelFormat >= NUMPF)
|
||||
throw new Exception("Invalid pixel format");
|
||||
public static int getPixelSize(int pixelFormat) {
|
||||
checkPixelFormat(pixelFormat);
|
||||
return pixelSize[pixelFormat];
|
||||
}
|
||||
|
||||
@@ -239,9 +236,8 @@ public final class TJ {
|
||||
*
|
||||
* @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");
|
||||
public static int getRedOffset(int pixelFormat) {
|
||||
checkPixelFormat(pixelFormat);
|
||||
return redOffset[pixelFormat];
|
||||
}
|
||||
|
||||
@@ -261,9 +257,8 @@ public final class TJ {
|
||||
*
|
||||
* @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");
|
||||
public static int getGreenOffset(int pixelFormat) {
|
||||
checkPixelFormat(pixelFormat);
|
||||
return greenOffset[pixelFormat];
|
||||
}
|
||||
|
||||
@@ -283,9 +278,8 @@ public final class TJ {
|
||||
*
|
||||
* @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");
|
||||
public static int getBlueOffset(int pixelFormat) {
|
||||
checkPixelFormat(pixelFormat);
|
||||
return blueOffset[pixelFormat];
|
||||
}
|
||||
|
||||
@@ -511,4 +505,15 @@ public final class TJ {
|
||||
static {
|
||||
TJLoader.load();
|
||||
}
|
||||
};
|
||||
|
||||
private static void checkPixelFormat(int pixelFormat) {
|
||||
if (pixelFormat < 0 || pixelFormat >= NUMPF)
|
||||
throw new IllegalArgumentException("Invalid pixel format");
|
||||
}
|
||||
|
||||
private static void checkSubsampling(int subsamp) {
|
||||
if (subsamp < 0 || subsamp >= NUMSAMP)
|
||||
throw new IllegalArgumentException("Invalid subsampling type");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class TJCompressor implements Closeable {
|
||||
if (handle == 0) init();
|
||||
if (srcImage == null || x < 0 || y < 0 || width < 1 || height < 1 ||
|
||||
pitch < 0 || pixelFormat < 0 || pixelFormat >= TJ.NUMPF)
|
||||
throw new Exception("Invalid argument in setSourceImage()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
srcBuf = srcImage;
|
||||
srcWidth = width;
|
||||
if (pitch == 0)
|
||||
@@ -195,13 +195,13 @@ public class TJCompressor implements Closeable {
|
||||
int height) throws Exception {
|
||||
if (handle == 0) init();
|
||||
if (srcImage == null || x < 0 || y < 0 || width < 0 || height < 0)
|
||||
throw new Exception("Invalid argument in setSourceImage()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
srcX = x;
|
||||
srcY = y;
|
||||
srcWidth = (width == 0) ? srcImage.getWidth(): width;
|
||||
srcHeight = (height == 0) ? srcImage.getHeight() : height;
|
||||
if (x + width > srcImage.getWidth() || y + height > srcImage.getHeight())
|
||||
throw new Exception("Compression region exceeds the bounds of the source image");
|
||||
throw new IllegalArgumentException("Compression region exceeds the bounds of the source image");
|
||||
|
||||
int pixelFormat;
|
||||
boolean intPixels = false;
|
||||
@@ -230,7 +230,7 @@ public class TJCompressor implements Closeable {
|
||||
pixelFormat = TJ.PF_BGRX;
|
||||
intPixels = true; break;
|
||||
default:
|
||||
throw new Exception("Unsupported BufferedImage format");
|
||||
throw new IllegalArgumentException("Unsupported BufferedImage format");
|
||||
}
|
||||
srcPixelFormat = pixelFormat;
|
||||
|
||||
@@ -247,7 +247,7 @@ public class TJCompressor implements Closeable {
|
||||
(ComponentSampleModel)srcImage.getSampleModel();
|
||||
int pixelSize = sm.getPixelStride();
|
||||
if (pixelSize != TJ.getPixelSize(pixelFormat))
|
||||
throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage");
|
||||
throw new IllegalArgumentException("Inconsistency between pixel format and pixel size in BufferedImage");
|
||||
srcPitch = sm.getScanlineStride();
|
||||
DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
|
||||
srcBuf = db.getData();
|
||||
@@ -266,7 +266,7 @@ public class TJCompressor implements Closeable {
|
||||
public void setSourceImage(YUVImage srcImage) throws Exception {
|
||||
if (handle == 0) init();
|
||||
if (srcImage == null)
|
||||
throw new Exception("Invalid argument in setSourceImage()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
srcYUVImage = srcImage;
|
||||
srcBuf = null;
|
||||
srcBufInt = null;
|
||||
@@ -293,9 +293,9 @@ public class TJCompressor implements Closeable {
|
||||
* subsequent compress/encode oeprations (one of
|
||||
* {@link TJ#SAMP_444 TJ.SAMP_*})
|
||||
*/
|
||||
public void setSubsamp(int newSubsamp) throws Exception {
|
||||
public void setSubsamp(int newSubsamp) {
|
||||
if (newSubsamp < 0 || newSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("Invalid argument in setSubsamp()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSubsamp()");
|
||||
subsamp = newSubsamp;
|
||||
}
|
||||
|
||||
@@ -305,9 +305,9 @@ public class TJCompressor implements Closeable {
|
||||
* @param quality the new JPEG image quality level (1 to 100, 1 = worst,
|
||||
* 100 = best)
|
||||
*/
|
||||
public void setJPEGQuality(int quality) throws Exception {
|
||||
public void setJPEGQuality(int quality) {
|
||||
if (quality < 1 || quality > 100)
|
||||
throw new Exception("Invalid argument in setJPEGQuality()");
|
||||
throw new IllegalArgumentException("Invalid argument in setJPEGQuality()");
|
||||
jpegQuality = quality;
|
||||
}
|
||||
|
||||
@@ -325,13 +325,13 @@ public class TJCompressor implements Closeable {
|
||||
*/
|
||||
public void compress(byte[] dstBuf, int flags) throws Exception {
|
||||
if (dstBuf == null || flags < 0)
|
||||
throw new Exception("Invalid argument in compress()");
|
||||
throw new IllegalArgumentException("Invalid argument in compress()");
|
||||
if (srcBuf == null && srcBufInt == null && srcYUVImage == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (jpegQuality < 0)
|
||||
throw new Exception("JPEG Quality not set");
|
||||
throw new IllegalStateException("JPEG Quality not set");
|
||||
if (subsamp < 0 && srcYUVImage == null)
|
||||
throw new Exception("Subsampling level not set");
|
||||
throw new IllegalStateException("Subsampling level not set");
|
||||
|
||||
if (srcYUVImage != null)
|
||||
compressedSize = compressFromYUV(srcYUVImage.getPlanes(),
|
||||
@@ -374,8 +374,7 @@ public class TJCompressor implements Closeable {
|
||||
* #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);
|
||||
checkSourceImage();
|
||||
byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
|
||||
compress(buf, flags);
|
||||
return buf;
|
||||
@@ -420,15 +419,14 @@ public class TJCompressor implements Closeable {
|
||||
*/
|
||||
public void encodeYUV(YUVImage dstImage, int flags) throws Exception {
|
||||
if (dstImage == null || flags < 0)
|
||||
throw new Exception("Invalid argument in encodeYUV()");
|
||||
throw new IllegalArgumentException("Invalid argument in encodeYUV()");
|
||||
if (srcBuf == null && srcBufInt == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (srcYUVImage != null)
|
||||
throw new Exception("Source image is not correct type");
|
||||
if (subsamp < 0)
|
||||
throw new Exception("Subsampling level not set");
|
||||
throw new IllegalStateException("Source image is not correct type");
|
||||
checkSubsampling();
|
||||
if (srcWidth != dstImage.getWidth() || srcHeight != dstImage.getHeight())
|
||||
throw new Exception("Destination image is the wrong size");
|
||||
throw new IllegalStateException("Destination image is the wrong size");
|
||||
|
||||
if (srcBufInt != null) {
|
||||
encodeYUV(srcBufInt, srcX, srcY, srcWidth, srcStride, srcHeight,
|
||||
@@ -448,11 +446,9 @@ public class TJCompressor implements Closeable {
|
||||
@Deprecated
|
||||
public void encodeYUV(byte[] dstBuf, int flags) throws Exception {
|
||||
if(dstBuf == null)
|
||||
throw new Exception("Invalid argument in encodeYUV()");
|
||||
if (srcWidth < 1 || srcHeight < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
if (subsamp < 0)
|
||||
throw new Exception("Subsampling level not set");
|
||||
throw new IllegalArgumentException("Invalid argument in encodeYUV()");
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
YUVImage yuvImage = new YUVImage(dstBuf, srcWidth, 4, srcHeight, subsamp);
|
||||
encodeYUV(yuvImage, flags);
|
||||
}
|
||||
@@ -475,12 +471,10 @@ public class TJCompressor implements Closeable {
|
||||
* @return a YUV planar image.
|
||||
*/
|
||||
public YUVImage encodeYUV(int pad, 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");
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
if(pad < 1 || ((pad & (pad - 1)) != 0))
|
||||
throw new Exception("Invalid argument in encodeYUV()");
|
||||
throw new IllegalStateException("Invalid argument in encodeYUV()");
|
||||
YUVImage yuvImage = new YUVImage(srcWidth, pad, srcHeight, subsamp);
|
||||
encodeYUV(yuvImage, flags);
|
||||
return yuvImage;
|
||||
@@ -508,10 +502,8 @@ public class TJCompressor implements Closeable {
|
||||
* @return a YUV planar image.
|
||||
*/
|
||||
public YUVImage encodeYUV(int[] strides, 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");
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
YUVImage yuvImage = new YUVImage(srcWidth, strides, srcHeight, subsamp);
|
||||
encodeYUV(yuvImage, flags);
|
||||
return yuvImage;
|
||||
@@ -522,10 +514,8 @@ public class TJCompressor implements Closeable {
|
||||
*/
|
||||
@Deprecated
|
||||
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");
|
||||
checkSourceImage();
|
||||
checkSubsampling();
|
||||
YUVImage yuvImage = new YUVImage(srcWidth, 4, srcHeight, subsamp);
|
||||
encodeYUV(yuvImage, flags);
|
||||
return yuvImage.getBuf();
|
||||
@@ -568,11 +558,13 @@ public class TJCompressor implements Closeable {
|
||||
/**
|
||||
* Free the native structures associated with this compressor instance.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (handle != 0)
|
||||
destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
close();
|
||||
@@ -630,6 +622,16 @@ public class TJCompressor implements Closeable {
|
||||
TJLoader.load();
|
||||
}
|
||||
|
||||
private void checkSourceImage() {
|
||||
if (srcWidth < 1 || srcHeight < 1)
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
}
|
||||
|
||||
private void checkSubsampling() {
|
||||
if (subsamp < 0)
|
||||
throw new IllegalStateException("Subsampling level not set");
|
||||
}
|
||||
|
||||
private long handle = 0;
|
||||
private byte[] srcBuf = null;
|
||||
private int[] srcBufInt = null;
|
||||
@@ -646,4 +648,4 @@ public class TJCompressor implements Closeable {
|
||||
private int compressedSize = 0;
|
||||
private int yuvPad = 4;
|
||||
private ByteOrder byteOrder = null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class TJDecompressor implements Closeable {
|
||||
public void setSourceImage(byte[] jpegImage, int imageSize)
|
||||
throws Exception {
|
||||
if (jpegImage == null || imageSize < 1)
|
||||
throw new Exception("Invalid argument in setSourceImage()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
jpegBuf = jpegImage;
|
||||
jpegBufSize = imageSize;
|
||||
decompressHeader(jpegBuf, jpegBufSize);
|
||||
@@ -123,7 +123,7 @@ public class TJDecompressor implements Closeable {
|
||||
*/
|
||||
public void setSourceImage(YUVImage srcImage) throws Exception {
|
||||
if (srcImage == null)
|
||||
throw new Exception("Invalid argument in setSourceImage()");
|
||||
throw new IllegalArgumentException("Invalid argument in setSourceImage()");
|
||||
yuvImage = srcImage;
|
||||
jpegBuf = null;
|
||||
jpegBufSize = 0;
|
||||
@@ -137,11 +137,11 @@ public class TJDecompressor implements Closeable {
|
||||
* @return the width of the source image (JPEG or YUV) associated with this
|
||||
* decompressor instance.
|
||||
*/
|
||||
public int getWidth() throws Exception {
|
||||
public int getWidth() {
|
||||
if (yuvImage != null)
|
||||
return yuvImage.getWidth();
|
||||
if (jpegWidth < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return jpegWidth;
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ public class TJDecompressor implements Closeable {
|
||||
* @return the height of the source image (JPEG or YUV) associated with this
|
||||
* decompressor instance.
|
||||
*/
|
||||
public int getHeight() throws Exception {
|
||||
public int getHeight() {
|
||||
if (yuvImage != null)
|
||||
return yuvImage.getHeight();
|
||||
if (jpegHeight < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return jpegHeight;
|
||||
}
|
||||
|
||||
@@ -168,13 +168,13 @@ public class TJDecompressor implements Closeable {
|
||||
* @return the level of chrominance subsampling used in the source image
|
||||
* (JPEG or YUV) associated with this decompressor instance.
|
||||
*/
|
||||
public int getSubsamp() throws Exception {
|
||||
public int getSubsamp() {
|
||||
if (yuvImage != null)
|
||||
return yuvImage.getSubsamp();
|
||||
if (jpegSubsamp < 0)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (jpegSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("JPEG header information is invalid");
|
||||
throw new IllegalStateException("JPEG header information is invalid");
|
||||
return jpegSubsamp;
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ public class TJDecompressor implements Closeable {
|
||||
* @return the colorspace used in the source image (JPEG or YUV) associated
|
||||
* with this decompressor instance.
|
||||
*/
|
||||
public int getColorspace() throws Exception {
|
||||
public int getColorspace() {
|
||||
if (yuvImage != null)
|
||||
return TJ.CS_YCbCr;
|
||||
if (jpegColorspace < 0)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (jpegColorspace >= TJ.NUMCS)
|
||||
throw new Exception("JPEG header information is invalid");
|
||||
throw new IllegalStateException("JPEG header information is invalid");
|
||||
return jpegColorspace;
|
||||
}
|
||||
|
||||
@@ -201,9 +201,9 @@ public class TJDecompressor implements Closeable {
|
||||
*
|
||||
* @return the JPEG image buffer associated with this decompressor instance.
|
||||
*/
|
||||
public byte[] getJPEGBuf() throws Exception {
|
||||
public byte[] getJPEGBuf() {
|
||||
if (jpegBuf == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return jpegBuf;
|
||||
}
|
||||
|
||||
@@ -214,9 +214,9 @@ public class TJDecompressor implements Closeable {
|
||||
* @return the size of the JPEG image (in bytes) associated with this
|
||||
* decompressor instance.
|
||||
*/
|
||||
public int getJPEGSize() throws Exception {
|
||||
public int getJPEGSize() {
|
||||
if (jpegBufSize < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return jpegBufSize;
|
||||
}
|
||||
|
||||
@@ -242,9 +242,9 @@ public class TJDecompressor implements Closeable {
|
||||
public int getScaledWidth(int desiredWidth, int desiredHeight)
|
||||
throws Exception {
|
||||
if (jpegWidth < 1 || jpegHeight < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (desiredWidth < 0 || desiredHeight < 0)
|
||||
throw new Exception("Invalid argument in getScaledWidth()");
|
||||
throw new IllegalArgumentException("Invalid argument in getScaledWidth()");
|
||||
TJScalingFactor[] sf = TJ.getScalingFactors();
|
||||
if (desiredWidth == 0)
|
||||
desiredWidth = jpegWidth;
|
||||
@@ -258,7 +258,7 @@ public class TJDecompressor implements Closeable {
|
||||
break;
|
||||
}
|
||||
if (scaledWidth > desiredWidth || scaledHeight > desiredHeight)
|
||||
throw new Exception("Could not scale down to desired image dimensions");
|
||||
throw new IllegalArgumentException("Could not scale down to desired image dimensions");
|
||||
return scaledWidth;
|
||||
}
|
||||
|
||||
@@ -284,9 +284,9 @@ public class TJDecompressor implements Closeable {
|
||||
public int getScaledHeight(int desiredWidth, int desiredHeight)
|
||||
throws Exception {
|
||||
if (jpegWidth < 1 || jpegHeight < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (desiredWidth < 0 || desiredHeight < 0)
|
||||
throw new Exception("Invalid argument in getScaledHeight()");
|
||||
throw new IllegalArgumentException("Invalid argument in getScaledHeight()");
|
||||
TJScalingFactor[] sf = TJ.getScalingFactors();
|
||||
if (desiredWidth == 0)
|
||||
desiredWidth = jpegWidth;
|
||||
@@ -300,7 +300,7 @@ public class TJDecompressor implements Closeable {
|
||||
break;
|
||||
}
|
||||
if (scaledWidth > desiredWidth || scaledHeight > desiredHeight)
|
||||
throw new Exception("Could not scale down to desired image dimensions");
|
||||
throw new IllegalArgumentException("Could not scale down to desired image dimensions");
|
||||
return scaledHeight;
|
||||
}
|
||||
|
||||
@@ -372,11 +372,11 @@ public class TJDecompressor implements Closeable {
|
||||
int pitch, int desiredHeight, int pixelFormat,
|
||||
int flags) throws Exception {
|
||||
if (jpegBuf == null && yuvImage == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (dstBuf == null || x < 0 || y < 0 || pitch < 0 ||
|
||||
(yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) ||
|
||||
pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
|
||||
throw new Exception("Invalid argument in decompress()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompress()");
|
||||
if (yuvImage != null)
|
||||
decodeYUV(yuvImage.getPlanes(), yuvImage.getOffsets(),
|
||||
yuvImage.getStrides(), yuvImage.getSubsamp(), dstBuf, x, y,
|
||||
@@ -433,7 +433,7 @@ public class TJDecompressor implements Closeable {
|
||||
if (pitch < 0 ||
|
||||
(yuvImage == null && (desiredWidth < 0 || desiredHeight < 0)) ||
|
||||
pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
|
||||
throw new Exception("Invalid argument in decompress()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompress()");
|
||||
int pixelSize = TJ.getPixelSize(pixelFormat);
|
||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||
@@ -464,18 +464,18 @@ public class TJDecompressor implements Closeable {
|
||||
*/
|
||||
public void decompressToYUV(YUVImage dstImage, int flags) throws Exception {
|
||||
if (jpegBuf == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (dstImage == null || flags < 0)
|
||||
throw new Exception("Invalid argument in decompressToYUV()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompressToYUV()");
|
||||
int scaledWidth = getScaledWidth(dstImage.getWidth(),
|
||||
dstImage.getHeight());
|
||||
int scaledHeight = getScaledHeight(dstImage.getWidth(),
|
||||
dstImage.getHeight());
|
||||
if (scaledWidth != dstImage.getWidth() ||
|
||||
scaledHeight != dstImage.getHeight())
|
||||
throw new Exception("YUVImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
|
||||
throw new IllegalArgumentException("YUVImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
|
||||
if (jpegSubsamp != dstImage.getSubsamp())
|
||||
throw new Exception("YUVImage subsampling level does not match that of the JPEG image");
|
||||
throw new IllegalArgumentException("YUVImage subsampling level does not match that of the JPEG image");
|
||||
|
||||
decompressToYUV(jpegBuf, jpegBufSize, dstImage.getPlanes(),
|
||||
dstImage.getOffsets(), dstImage.getWidth(),
|
||||
@@ -534,13 +534,13 @@ public class TJDecompressor implements Closeable {
|
||||
int desiredHeight,
|
||||
int flags) throws Exception {
|
||||
if (flags < 0)
|
||||
throw new Exception("Invalid argument in decompressToYUV()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompressToYUV()");
|
||||
if (jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (jpegSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("JPEG header information is invalid");
|
||||
throw new IllegalStateException("JPEG header information is invalid");
|
||||
if (yuvImage != null)
|
||||
throw new Exception("Source image is the wrong type");
|
||||
throw new IllegalStateException("Source image is the wrong type");
|
||||
|
||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||
@@ -587,13 +587,13 @@ public class TJDecompressor implements Closeable {
|
||||
public YUVImage decompressToYUV(int desiredWidth, int pad, int desiredHeight,
|
||||
int flags) throws Exception {
|
||||
if (flags < 0)
|
||||
throw new Exception("Invalid argument in decompressToYUV()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompressToYUV()");
|
||||
if (jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (jpegSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("JPEG header information is invalid");
|
||||
throw new IllegalStateException("JPEG header information is invalid");
|
||||
if (yuvImage != null)
|
||||
throw new Exception("Source image is the wrong type");
|
||||
throw new IllegalStateException("Source image is the wrong type");
|
||||
|
||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||
@@ -679,11 +679,11 @@ public class TJDecompressor implements Closeable {
|
||||
int stride, int desiredHeight, int pixelFormat,
|
||||
int flags) throws Exception {
|
||||
if (jpegBuf == null && yuvImage == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (dstBuf == null || x < 0 || y < 0 || stride < 0 ||
|
||||
(yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) ||
|
||||
pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
|
||||
throw new Exception("Invalid argument in decompress()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompress()");
|
||||
if (yuvImage != null)
|
||||
decodeYUV(yuvImage.getPlanes(), yuvImage.getOffsets(),
|
||||
yuvImage.getStrides(), yuvImage.getSubsamp(), dstBuf, x, y,
|
||||
@@ -712,7 +712,7 @@ public class TJDecompressor implements Closeable {
|
||||
*/
|
||||
public void decompress(BufferedImage dstImage, int flags) throws Exception {
|
||||
if (dstImage == null || flags < 0)
|
||||
throw new Exception("Invalid argument in decompress()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompress()");
|
||||
int desiredWidth = dstImage.getWidth();
|
||||
int desiredHeight = dstImage.getHeight();
|
||||
int scaledWidth, scaledHeight;
|
||||
@@ -720,14 +720,14 @@ public class TJDecompressor implements Closeable {
|
||||
if (yuvImage != null) {
|
||||
if (desiredWidth != yuvImage.getWidth() ||
|
||||
desiredHeight != yuvImage.getHeight())
|
||||
throw new Exception("BufferedImage dimensions do not match the dimensions of the source image.");
|
||||
throw new IllegalArgumentException("BufferedImage dimensions do not match the dimensions of the source image.");
|
||||
scaledWidth = yuvImage.getWidth();
|
||||
scaledHeight = yuvImage.getHeight();
|
||||
} else {
|
||||
scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||
scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||
if (scaledWidth != desiredWidth || scaledHeight != desiredHeight)
|
||||
throw new Exception("BufferedImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
|
||||
throw new IllegalArgumentException("BufferedImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
|
||||
}
|
||||
int pixelFormat; boolean intPixels = false;
|
||||
if (byteOrder == null)
|
||||
@@ -760,7 +760,7 @@ public class TJDecompressor implements Closeable {
|
||||
pixelFormat = TJ.PF_BGRA;
|
||||
intPixels = true; break;
|
||||
default:
|
||||
throw new Exception("Unsupported BufferedImage format");
|
||||
throw new IllegalArgumentException("Unsupported BufferedImage format");
|
||||
}
|
||||
WritableRaster wr = dstImage.getRaster();
|
||||
if (intPixels) {
|
||||
@@ -776,7 +776,7 @@ public class TJDecompressor implements Closeable {
|
||||
pixelFormat, flags);
|
||||
else {
|
||||
if (jpegBuf == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
decompress(jpegBuf, jpegBufSize, buf, 0, 0, scaledWidth, stride,
|
||||
scaledHeight, pixelFormat, flags);
|
||||
}
|
||||
@@ -785,7 +785,7 @@ public class TJDecompressor implements Closeable {
|
||||
(ComponentSampleModel)dstImage.getSampleModel();
|
||||
int pixelSize = sm.getPixelStride();
|
||||
if (pixelSize != TJ.getPixelSize(pixelFormat))
|
||||
throw new Exception("Inconsistency between pixel format and pixel size in BufferedImage");
|
||||
throw new IllegalArgumentException("Inconsistency between pixel format and pixel size in BufferedImage");
|
||||
int pitch = sm.getScanlineStride();
|
||||
DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
|
||||
byte[] buf = db.getData();
|
||||
@@ -822,7 +822,7 @@ public class TJDecompressor implements Closeable {
|
||||
throws Exception {
|
||||
if ((yuvImage == null && (desiredWidth < 0 || desiredHeight < 0)) ||
|
||||
flags < 0)
|
||||
throw new Exception("Invalid argument in decompress()");
|
||||
throw new IllegalArgumentException("Invalid argument in decompress()");
|
||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||
BufferedImage img = new BufferedImage(scaledWidth, scaledHeight,
|
||||
@@ -834,11 +834,13 @@ public class TJDecompressor implements Closeable {
|
||||
/**
|
||||
* Free the native structures associated with this decompressor instance.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (handle != 0)
|
||||
destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
close();
|
||||
@@ -899,4 +901,4 @@ public class TJDecompressor implements Closeable {
|
||||
protected int jpegSubsamp = -1;
|
||||
protected int jpegColorspace = -1;
|
||||
private ByteOrder byteOrder = null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ final class TJLoader {
|
||||
static void load() {
|
||||
System.loadLibrary("@TURBOJPEG_DLL_NAME@");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -56,4 +56,4 @@ final class TJLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ package org.libjpegturbo.turbojpeg;
|
||||
*/
|
||||
public class TJScalingFactor {
|
||||
|
||||
public TJScalingFactor(int num, int denom) throws Exception {
|
||||
public TJScalingFactor(int num, int denom) {
|
||||
if (num < 1 || denom < 1)
|
||||
throw new Exception("Numerator and denominator must be >= 1");
|
||||
throw new IllegalArgumentException("Numerator and denominator must be >= 1");
|
||||
this.num = num;
|
||||
this.denom = denom;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class TJScalingFactor {
|
||||
* <code>other</code> have the same numerator and denominator.
|
||||
*/
|
||||
public boolean equals(TJScalingFactor other) {
|
||||
return (this.num == other.num && this.denom == other.denom);
|
||||
return this.num == other.num && this.denom == other.denom;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ public class TJScalingFactor {
|
||||
* 1/1.
|
||||
*/
|
||||
public boolean isOne() {
|
||||
return (num == 1 && denom == 1);
|
||||
return num == 1 && denom == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,4 +100,4 @@ public class TJScalingFactor {
|
||||
* Denominator
|
||||
*/
|
||||
private int denom = 1;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class TJTransformer extends TJDecompressor {
|
||||
public void transform(byte[][] dstBufs, TJTransform[] transforms,
|
||||
int flags) throws Exception {
|
||||
if (jpegBuf == null)
|
||||
throw new Exception("JPEG buffer not initialized");
|
||||
throw new IllegalStateException("JPEG buffer not initialized");
|
||||
transformedSizes = transform(jpegBuf, jpegBufSize, dstBufs, transforms,
|
||||
flags);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class TJTransformer extends TJDecompressor {
|
||||
throws Exception {
|
||||
byte[][] dstBufs = new byte[transforms.length][];
|
||||
if (jpegWidth < 1 || jpegHeight < 1)
|
||||
throw new Exception("JPEG buffer not initialized");
|
||||
throw new IllegalStateException("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) {
|
||||
@@ -143,9 +143,9 @@ public class TJTransformer extends TJDecompressor {
|
||||
* @return an array containing the sizes of the transformed JPEG images
|
||||
* generated by the most recent transform operation.
|
||||
*/
|
||||
public int[] getTransformedSizes() throws Exception {
|
||||
public int[] getTransformedSizes() {
|
||||
if (transformedSizes == null)
|
||||
throw new Exception("No image has been transformed yet");
|
||||
throw new IllegalStateException("No image has been transformed yet");
|
||||
return transformedSizes;
|
||||
}
|
||||
|
||||
@@ -159,4 +159,4 @@ public class TJTransformer extends TJDecompressor {
|
||||
}
|
||||
|
||||
private int[] transformedSizes = null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -218,12 +218,12 @@ public class YUVImage {
|
||||
int height, int subsamp, boolean alloc) throws Exception {
|
||||
if ((planes == null && !alloc) || width < 1 || height < 1 || subsamp < 0 ||
|
||||
subsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("Invalid argument in YUVImage::setBuf()");
|
||||
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
||||
|
||||
int nc = (subsamp == TJ.SAMP_GRAY ? 1 : 3);
|
||||
if (planes.length != nc || (offsets != null && offsets.length != nc) ||
|
||||
(strides != null && strides.length != nc))
|
||||
throw new Exception("YUVImage::setBuf(): planes, offsets, or strides array is the wrong size");
|
||||
throw new IllegalArgumentException("YUVImage::setBuf(): planes, offsets, or strides array is the wrong size");
|
||||
|
||||
if (offsets == null)
|
||||
offsets = new int[nc];
|
||||
@@ -239,15 +239,15 @@ public class YUVImage {
|
||||
strides[i] = pw;
|
||||
if (alloc) {
|
||||
if (strides[i] < pw)
|
||||
throw new Exception("Stride must be >= plane width when allocating a new YUV image");
|
||||
throw new IllegalArgumentException("Stride must be >= plane width when allocating a new YUV image");
|
||||
planes[i] = new byte[strides[i] * ph];
|
||||
}
|
||||
if (planes[i] == null || offsets[i] < 0)
|
||||
throw new Exception("Invalid argument in YUVImage::setBuf()");
|
||||
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
||||
if (strides[i] < 0 && offsets[i] - planeSize + pw < 0)
|
||||
throw new Exception("Stride for plane " + i + " would cause memory to be accessed below plane boundary");
|
||||
throw new IllegalArgumentException("Stride for plane " + i + " would cause memory to be accessed below plane boundary");
|
||||
if (planes[i].length < offsets[i] + planeSize)
|
||||
throw new Exception("Image plane " + i + " is not large enough");
|
||||
throw new IllegalArgumentException("Image plane " + i + " is not large enough");
|
||||
}
|
||||
|
||||
yuvPlanes = planes;
|
||||
@@ -282,10 +282,10 @@ public class YUVImage {
|
||||
int subsamp) throws Exception {
|
||||
if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) ||
|
||||
height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP)
|
||||
throw new Exception("Invalid argument in YUVImage::setBuf()");
|
||||
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
||||
if (yuvImage.length < TJ.bufSizeYUV(width, pad, height, subsamp))
|
||||
throw new Exception("YUV image buffer is not large enough");
|
||||
|
||||
throw new IllegalArgumentException("YUV image buffer is not large enough");
|
||||
|
||||
int nc = (subsamp == TJ.SAMP_GRAY ? 1 : 3);
|
||||
byte[][] planes = new byte[nc][];
|
||||
int[] strides = new int[nc];
|
||||
@@ -311,9 +311,9 @@ public class YUVImage {
|
||||
*
|
||||
* @return the width of the YUV image (or subregion)
|
||||
*/
|
||||
public int getWidth() throws Exception {
|
||||
public int getWidth() {
|
||||
if (yuvWidth < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvWidth;
|
||||
}
|
||||
|
||||
@@ -322,9 +322,9 @@ public class YUVImage {
|
||||
*
|
||||
* @return the height of the YUV image (or subregion)
|
||||
*/
|
||||
public int getHeight() throws Exception {
|
||||
public int getHeight() {
|
||||
if (yuvHeight < 1)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvHeight;
|
||||
}
|
||||
|
||||
@@ -334,11 +334,11 @@ public class YUVImage {
|
||||
*
|
||||
* @return the line padding used in the YUV image buffer
|
||||
*/
|
||||
public int getPad() throws Exception {
|
||||
public int getPad() {
|
||||
if (yuvPlanes == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
if (yuvPad < 1 || ((yuvPad & (yuvPad - 1)) != 0))
|
||||
throw new Exception("Image is not stored in a unified buffer");
|
||||
throw new IllegalStateException("Image is not stored in a unified buffer");
|
||||
return yuvPad;
|
||||
}
|
||||
|
||||
@@ -347,9 +347,9 @@ public class YUVImage {
|
||||
*
|
||||
* @return the number of bytes per line of each plane in the YUV image
|
||||
*/
|
||||
public int[] getStrides() throws Exception {
|
||||
public int[] getStrides() {
|
||||
if (yuvStrides == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvStrides;
|
||||
}
|
||||
|
||||
@@ -360,9 +360,9 @@ public class YUVImage {
|
||||
* @return the offsets (in bytes) of each plane within the planes of a larger
|
||||
* YUV image
|
||||
*/
|
||||
public int[] getOffsets() throws Exception {
|
||||
public int[] getOffsets() {
|
||||
if (yuvOffsets == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvOffsets;
|
||||
}
|
||||
|
||||
@@ -372,9 +372,9 @@ public class YUVImage {
|
||||
*
|
||||
* @return the level of chrominance subsampling used in the YUV image
|
||||
*/
|
||||
public int getSubsamp() throws Exception {
|
||||
public int getSubsamp() {
|
||||
if (yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvSubsamp;
|
||||
}
|
||||
|
||||
@@ -384,9 +384,9 @@ public class YUVImage {
|
||||
*
|
||||
* @return the YUV image planes
|
||||
*/
|
||||
public byte[][] getPlanes() throws Exception {
|
||||
public byte[][] getPlanes() {
|
||||
if (yuvPlanes == null)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return yuvPlanes;
|
||||
}
|
||||
|
||||
@@ -396,13 +396,13 @@ public class YUVImage {
|
||||
*
|
||||
* @return the YUV image buffer
|
||||
*/
|
||||
public byte[] getBuf() throws Exception {
|
||||
public byte[] getBuf() {
|
||||
if (yuvPlanes == null || yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
int nc = (yuvSubsamp == TJ.SAMP_GRAY ? 1 : 3);
|
||||
for (int i = 1; i < nc; i++) {
|
||||
if (yuvPlanes[i] != yuvPlanes[0])
|
||||
throw new Exception("Image is not stored in a unified buffer");
|
||||
throw new IllegalStateException("Image is not stored in a unified buffer");
|
||||
}
|
||||
return yuvPlanes[0];
|
||||
}
|
||||
@@ -415,13 +415,13 @@ public class YUVImage {
|
||||
*/
|
||||
public int getSize() throws Exception {
|
||||
if (yuvPlanes == null || yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP)
|
||||
throw new Exception(NO_ASSOC_ERROR);
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
int nc = (yuvSubsamp == TJ.SAMP_GRAY ? 1 : 3);
|
||||
if (yuvPad < 1)
|
||||
throw new Exception("Image is not stored in a unified buffer");
|
||||
throw new IllegalStateException("Image is not stored in a unified buffer");
|
||||
for (int i = 1; i < nc; i++) {
|
||||
if (yuvPlanes[i] != yuvPlanes[0])
|
||||
throw new Exception("Image is not stored in a unified buffer");
|
||||
throw new IllegalStateException("Image is not stored in a unified buffer");
|
||||
}
|
||||
return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
|
||||
}
|
||||
@@ -438,4 +438,4 @@ public class YUVImage {
|
||||
protected int yuvWidth = 0;
|
||||
protected int yuvHeight = 0;
|
||||
protected int yuvSubsamp = -1;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user