[2] Added a new libjpeg API function (jpeg_skip_scanlines()) that can be used
to partially decode a JPEG image. See libjpeg.txt for more details.
+[3] The TJCompressor and TJDecompressor classes in the TurboJPEG Java API now
+implement the Closeable interface, so those classes can be used with a
+try-with-resources statement.
+
1.4.1
=====
<div class="description">
<ul class="blockList">
<li class="blockList">
+<dl>
+<dt>All Implemented Interfaces:</dt>
+<dd>java.io.Closeable, java.lang.AutoCloseable</dd>
+</dl>
<hr>
<br>
<pre>public class <span class="strong">TJCompressor</span>
-extends java.lang.Object</pre>
+extends java.lang.Object
+implements java.io.Closeable</pre>
<div class="block">TurboJPEG compressor</div>
</li>
</ul>
<li class="blockList">
<h4>close</h4>
<pre>public void close()
- throws java.lang.Exception</pre>
+ throws java.io.IOException</pre>
<div class="block">Free the native structures associated with this compressor instance.</div>
-<dl><dt><span class="strong">Throws:</span></dt>
-<dd><code>java.lang.Exception</code></dd></dl>
+<dl>
+<dt><strong>Specified by:</strong></dt>
+<dd><code>close</code> in interface <code>java.io.Closeable</code></dd>
+<dt><strong>Specified by:</strong></dt>
+<dd><code>close</code> in interface <code>java.lang.AutoCloseable</code></dd>
+<dt><span class="strong">Throws:</span></dt>
+<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="finalize()">
<ul class="blockList">
<li class="blockList">
<dl>
+<dt>All Implemented Interfaces:</dt>
+<dd>java.io.Closeable, java.lang.AutoCloseable</dd>
+</dl>
+<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../org/libjpegturbo/turbojpeg/TJTransformer.html" title="class in org.libjpegturbo.turbojpeg">TJTransformer</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="strong">TJDecompressor</span>
-extends java.lang.Object</pre>
+extends java.lang.Object
+implements java.io.Closeable</pre>
<div class="block">TurboJPEG decompressor</div>
</li>
</ul>
<li class="blockList">
<h4>close</h4>
<pre>public void close()
- throws java.lang.Exception</pre>
+ throws java.io.IOException</pre>
<div class="block">Free the native structures associated with this decompressor instance.</div>
-<dl><dt><span class="strong">Throws:</span></dt>
-<dd><code>java.lang.Exception</code></dd></dl>
+<dl>
+<dt><strong>Specified by:</strong></dt>
+<dd><code>close</code> in interface <code>java.io.Closeable</code></dd>
+<dt><strong>Specified by:</strong></dt>
+<dd><code>close</code> in interface <code>java.lang.AutoCloseable</code></dd>
+<dt><span class="strong">Throws:</span></dt>
+<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="finalize()">
<div class="description">
<ul class="blockList">
<li class="blockList">
+<dl>
+<dt>All Implemented Interfaces:</dt>
+<dd>java.io.Closeable, java.lang.AutoCloseable</dd>
+</dl>
<hr>
<br>
<pre>public class <span class="strong">TJTransformer</span>
</ul>
</li>
<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJ</span></a></li>
-<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a></li>
-<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJDecompressor</span></a>
+<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a> (implements java.io.Closeable)</li>
+<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJDecompressor</span></a> (implements java.io.Closeable)
<ul>
<li type="circle">org.libjpegturbo.turbojpeg.<a href="../../../org/libjpegturbo/turbojpeg/TJTransformer.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJTransformer</span></a></li>
</ul>
</ul>
</li>
<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJ</span></a></li>
-<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a></li>
-<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJDecompressor</span></a>
+<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a> (implements java.io.Closeable)</li>
+<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJDecompressor</span></a> (implements java.io.Closeable)
<ul>
<li type="circle">org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJTransformer.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJTransformer</span></a></li>
</ul>
import java.awt.image.*;
import java.nio.*;
+import java.io.*;
/**
* TurboJPEG compressor
*/
-public class TJCompressor {
+public class TJCompressor implements Closeable {
private static final String NO_ASSOC_ERROR =
"No source image is associated with this instance";
/**
* Free the native structures associated with this compressor instance.
*/
- public void close() throws Exception {
+ public void close() throws IOException {
if (handle != 0)
destroy();
}
private native void init() throws Exception;
- private native void destroy() throws Exception;
+ private native void destroy() throws IOException;
// JPEG size in bytes is returned
private native int compress(byte[] srcBuf, int width, int pitch,
import java.awt.image.*;
import java.nio.*;
+import java.io.*;
/**
* TurboJPEG decompressor
*/
-public class TJDecompressor {
+public class TJDecompressor implements Closeable {
private static final String NO_ASSOC_ERROR =
"No JPEG image is associated with this instance";
/**
* Free the native structures associated with this decompressor instance.
*/
- public void close() throws Exception {
+ public void close() throws IOException {
if (handle != 0)
destroy();
}
private native void init() throws Exception;
- private native void destroy() throws Exception;
+ private native void destroy() throws IOException;
private native void decompressHeader(byte[] srcBuf, int size)
throws Exception;
/*
- * Copyright (C)2011-2014 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2015 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:
goto bailout; \
}
+#define _throwio(msg) { \
+ jclass _exccls=(*env)->FindClass(env, "java/io/IOException"); \
+ if(!_exccls) goto bailout; \
+ (*env)->ThrowNew(env, _exccls, msg); \
+ goto bailout; \
+}
+
#define bailif0(f) {if(!(f)) { \
char temps[80]; \
snprintf(temps, 80, "Unexpected NULL condition in line %d", __LINE__); \
gethandle();
- if(tjDestroy(handle)==-1) _throw(tjGetErrorStr());
+ if(tjDestroy(handle)==-1) _throwio(tjGetErrorStr());
(*env)->SetLongField(env, obj, _fid, 0);
bailout: