Add x, y parameters to TJDecompressor so that it can be used to decompress to an arbitrary position in the destination image (TurboVNC needs this.)


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@832 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 475d830..d4808e8 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -34,6 +34,9 @@
 images (specifically, images in which the component count was erroneously set
 to a large value) would cause libjpeg-turbo to segfault.
 
+[8] Extended the TurboJPEG Java API so that it can be used to decompress a
+JPEG image into an arbitrary position in a large output buffer.
+
 
 1.2.0
 =====
diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html
index a2b0499..73d5fb9 100644
--- a/java/doc/allclasses-frame.html
+++ b/java/doc/allclasses-frame.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 All Classes
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/allclasses-noframe.html b/java/doc/allclasses-noframe.html
index e3c96ca..8392bfd 100644
--- a/java/doc/allclasses-noframe.html
+++ b/java/doc/allclasses-noframe.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 All Classes
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/constant-values.html b/java/doc/constant-values.html
index 667e3ef..ca1f208 100644
--- a/java/doc/constant-values.html
+++ b/java/doc/constant-values.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 Constant Field Values
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html
index 8654476..de71e8c 100644
--- a/java/doc/deprecated-list.html
+++ b/java/doc/deprecated-list.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 Deprecated List
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/help-doc.html b/java/doc/help-doc.html
index 9d609c3..5beef37 100644
--- a/java/doc/help-doc.html
+++ b/java/doc/help-doc.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 API Help
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/index-all.html b/java/doc/index-all.html
index 1589d6d..8ee0112 100644
--- a/java/doc/index-all.html
+++ b/java/doc/index-all.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 Index
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="./stylesheet.css" TITLE="Style">
 
@@ -129,6 +129,10 @@
 <A NAME="_D_"><!-- --></A><H2>
 <B>D</B></H2>
 <DL>
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><B>decompress(byte[], int, int, int, int, int, int, int)</B></A> - 
+Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
+<DD>Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.
 <DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><B>decompress(byte[], int, int, int, int, int)</B></A> - 
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
 <DD>Decompress the JPEG source image associated with this decompressor
@@ -137,6 +141,10 @@
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
 <DD>Decompress the JPEG source image associated with this decompressor
  instance and return a buffer containing the decompressed image.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int[], int, int, int, int, int, int, int)"><B>decompress(int[], int, int, int, int, int, int, int)</B></A> - 
+Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
+<DD>Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.
 <DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(java.awt.image.BufferedImage, int)"><B>decompress(BufferedImage, int)</B></A> - 
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
 <DD>Decompress the JPEG source image associated with this decompressor
diff --git a/java/doc/index.html b/java/doc/index.html
index 8e6f370..9b36a3f 100644
--- a/java/doc/index.html
+++ b/java/doc/index.html
@@ -2,7 +2,7 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc on Sun Dec 18 20:09:44 CST 2011-->
+<!-- Generated by javadoc on Wed Jun 06 03:10:33 CDT 2012-->
 <TITLE>
 Generated Documentation (Untitled)
 </TITLE>
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
index b3300e2..ac949a8 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJ
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html
index ba5b1da..e21a954 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJCompressor
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
index 5a93ded..49911ab 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJCustomFilter
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
index 8eabb59..de5dcb9 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJDecompressor
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -242,6 +242,38 @@
 </TR>
 <TR BGCOLOR="white" CLASS="TableRowColor">
 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)">decompress</A></B>(byte[]&nbsp;dstBuf,
+           int&nbsp;x,
+           int&nbsp;y,
+           int&nbsp;desiredWidth,
+           int&nbsp;pitch,
+           int&nbsp;desiredHeight,
+           int&nbsp;pixelFormat,
+           int&nbsp;flags)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int[], int, int, int, int, int, int, int)">decompress</A></B>(int[]&nbsp;dstBuf,
+           int&nbsp;x,
+           int&nbsp;y,
+           int&nbsp;desiredWidth,
+           int&nbsp;stride,
+           int&nbsp;desiredHeight,
+           int&nbsp;pixelFormat,
+           int&nbsp;flags)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 <CODE>&nbsp;java.awt.image.BufferedImage</CODE></FONT></TD>
 <TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int)">decompress</A></B>(int&nbsp;desiredWidth,
            int&nbsp;desiredHeight,
@@ -688,10 +720,12 @@
 </DL>
 <HR>
 
-<A NAME="decompress(byte[], int, int, int, int, int)"><!-- --></A><H3>
+<A NAME="decompress(byte[], int, int, int, int, int, int, int)"><!-- --></A><H3>
 decompress</H3>
 <PRE>
 public void <B>decompress</B>(byte[]&nbsp;dstBuf,
+                       int&nbsp;x,
+                       int&nbsp;y,
                        int&nbsp;desiredWidth,
                        int&nbsp;pitch,
                        int&nbsp;desiredHeight,
@@ -707,7 +741,13 @@
  buffer should normally be <code>pitch * scaledHeight</code> bytes in size,
  where <code>scaledHeight</code> can be determined by calling <code>
  scalingFactor.<A HREF="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#getScaled(int)"><CODE>getScaled</CODE></A>(jpegHeight)
- </code> with one of the scaling factors returned from <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#getScalingFactors()"><CODE>TJ.getScalingFactors()</CODE></A> or by calling <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)"><CODE>getScaledHeight(int, int)</CODE></A>.<DD><CODE>desiredWidth</CODE> - desired width (in pixels) of the decompressed image.
+ </code> with one of the scaling factors returned from <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#getScalingFactors()"><CODE>TJ.getScalingFactors()</CODE></A> or by calling <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)"><CODE>getScaledHeight(int, int)</CODE></A>.  However,
+ the buffer may also be larger than the dimensions of the JPEG image, in
+ which case the <code>x</code>, <code>y</code>, and <code>pitch</code>
+ parameters can be used to specify the region into which the JPEG image
+ should be decompressed.<DD><CODE>x</CODE> - x offset (in pixels) of the region into which the JPEG image
+ should be decompressed, relative to the start of <code>dstBuf</code>.<DD><CODE>y</CODE> - y offset (in pixels) of the region into which the JPEG image
+ should be decompressed, relative to the start of <code>dstBuf</code>.<DD><CODE>desiredWidth</CODE> - 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
@@ -716,7 +756,8 @@
  considered when determining the scaled image size.)<DD><CODE>pitch</CODE> - 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:
+ pad each line of the decompressed image to a 4-byte boundary or to
+ decompress the JPEG image into a region of a larger image.  NOTE:
  <code>scaledWidth</code> can be determined by calling <code>
  scalingFactor.<A HREF="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#getScaled(int)"><CODE>getScaled</CODE></A>(jpegWidth)
  </code> or by calling <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)"><CODE>getScaledWidth(int, int)</CODE></A>.  Setting this parameter to
@@ -735,6 +776,37 @@
 </DL>
 <HR>
 
+<A NAME="decompress(byte[], int, int, int, int, int)"><!-- --></A><H3>
+decompress</H3>
+<PRE>
+public void <B>decompress</B>(byte[]&nbsp;dstBuf,
+                       int&nbsp;desiredWidth,
+                       int&nbsp;pitch,
+                       int&nbsp;desiredHeight,
+                       int&nbsp;pixelFormat,
+                       int&nbsp;flags)
+                throws java.lang.Exception</PRE>
+<DL>
+<DD>Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.
+<P>
+<DD><DL>
+<DT><B>Parameters:</B><DD><CODE>dstBuf</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>desiredWidth</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>pitch</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>desiredHeight</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>pixelFormat</CODE> - pixel format of the decompressed image (one of
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.PF_*</CODE></A>)<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
 <A NAME="decompress(int, int, int, int, int)"><!-- --></A><H3>
 decompress</H3>
 <PRE>
@@ -750,9 +822,12 @@
 <P>
 <DD><DL>
 <DT><B>Parameters:</B><DD><CODE>desiredWidth</CODE> - see
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int)</CODE></A> for description<DD><CODE>pitch</CODE> - see
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int)</CODE></A> for description<DD><CODE>desiredHeight</CODE> - see
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int)</CODE></A> for description<DD><CODE>pixelFormat</CODE> - pixel format of the decompressed image (one of
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>pitch</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>desiredHeight</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
+ for description<DD><CODE>pixelFormat</CODE> - pixel format of the decompressed image (one of
  <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.PF_*</CODE></A>)<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Returns:</B><DD>a buffer containing the decompressed image
 <DT><B>Throws:</B>
@@ -806,6 +881,59 @@
 </DL>
 <HR>
 
+<A NAME="decompress(int[], int, int, int, int, int, int, int)"><!-- --></A><H3>
+decompress</H3>
+<PRE>
+public void <B>decompress</B>(int[]&nbsp;dstBuf,
+                       int&nbsp;x,
+                       int&nbsp;y,
+                       int&nbsp;desiredWidth,
+                       int&nbsp;stride,
+                       int&nbsp;desiredHeight,
+                       int&nbsp;pixelFormat,
+                       int&nbsp;flags)
+                throws java.lang.Exception</PRE>
+<DL>
+<DD>Decompress the JPEG source image associated with this decompressor
+ instance and output a decompressed image to the given destination buffer.
+<P>
+<DD><DL>
+<DT><B>Parameters:</B><DD><CODE>dstBuf</CODE> - buffer that will receive the decompressed image.  This
+ buffer should normally be <code>stride * scaledHeight</code> pixels in
+ size, where <code>scaledHeight</code> can be determined by calling <code>
+ scalingFactor.<A HREF="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#getScaled(int)"><CODE>getScaled</CODE></A>(jpegHeight)
+ </code> with one of the scaling factors returned from <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#getScalingFactors()"><CODE>TJ.getScalingFactors()</CODE></A> or by calling <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)"><CODE>getScaledHeight(int, int)</CODE></A>.  However,
+ the buffer may also be larger than the dimensions of the JPEG image, in
+ which case the <code>x</code>, <code>y</code>, and <code>stride</code>
+ parameters can be used to specify the region into which the JPEG image
+ should be decompressed.<DD><CODE>x</CODE> - x offset (in pixels) of the region into which the JPEG image
+ should be decompressed, relative to the start of <code>dstBuf</code>.<DD><CODE>y</CODE> - y offset (in pixels) of the region into which the JPEG image
+ should be decompressed, relative to the start of <code>dstBuf</code>.<DD><CODE>desiredWidth</CODE> - 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.)<DD><CODE>stride</CODE> - pixels per line of the destination image.  Normally, this
+ should be set to <code>scaledWidth</code>, but you can use this to, for
+ instance, decompress the JPEG image into a region of a larger image.
+ NOTE: <code>scaledWidth</code> can be determined by calling <code>
+ scalingFactor.<A HREF="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#getScaled(int)"><CODE>getScaled</CODE></A>(jpegWidth)
+ </code> or by calling <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)"><CODE>getScaledWidth(int, int)</CODE></A>.  Setting this parameter to
+ 0 is the equivalent of setting it to <code>scaledWidth</code>.<DD><CODE>desiredHeight</CODE> - 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.)<DD><CODE>pixelFormat</CODE> - pixel format of the decompressed image (one of
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.PF_*</CODE></A>)<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
 <A NAME="decompress(java.awt.image.BufferedImage, int)"><!-- --></A><H3>
 decompress</H3>
 <PRE>
@@ -841,8 +969,10 @@
 <P>
 <DD><DL>
 <DT><B>Parameters:</B><DD><CODE>desiredWidth</CODE> - see
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int)</CODE></A> for description<DD><CODE>desiredHeight</CODE> - see
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int)</CODE></A> for description<DD><CODE>bufferedImageType</CODE> - the image type of the newly-created
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A> for
+ description<DD><CODE>desiredHeight</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A> for
+ description<DD><CODE>bufferedImageType</CODE> - the image type of the newly-created
  <code>BufferedImage</code> instance (for instance,
  <code>BufferedImage.TYPE_INT_RGB</code>)<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Returns:</B><DD>a <code>BufferedImage</code> instance containing the
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html
index decf430..68e64b8 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJScalingFactor
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
index b207637..ff4a539 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJTransform
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
index 9e74a6e..929b412 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 TJTransformer
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -205,7 +205,7 @@
 <TH ALIGN="left"><B>Methods inherited from class org.libjpegturbo.turbojpeg.<A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A></B></TH>
 </TR>
 <TR BGCOLOR="white" CLASS="TableRowColor">
-<TD><CODE><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#close()">close</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(java.awt.image.BufferedImage, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#finalize()">finalize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getHeight()">getHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGBuf()">getJPEGBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGSize()">getJPEGSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)">getScaledHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)">getScaledWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getSubsamp()">getSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getWidth()">getWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage</A></CODE></TD>
+<TD><CODE><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#close()">close</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(java.awt.image.BufferedImage, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#finalize()">finalize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getHeight()">getHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGBuf()">getJPEGBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGSize()">getJPEGSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)">getScaledHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)">getScaledWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getSubsamp()">getSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getWidth()">getWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage</A></CODE></TD>
 </TR>
 </TABLE>
 &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html
index 50ede9f..f4b8348 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 org.libjpegturbo.turbojpeg
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html
index d98f285..acca4fd 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 org.libjpegturbo.turbojpeg
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html
index 319c1eb..41b9c16 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 org.libjpegturbo.turbojpeg Class Hierarchy
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/overview-tree.html b/java/doc/overview-tree.html
index e3839ee..07caa97 100644
--- a/java/doc/overview-tree.html
+++ b/java/doc/overview-tree.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 Class Hierarchy
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/doc/serialized-form.html b/java/doc/serialized-form.html
index 39ec91f..b5fdd4d 100644
--- a/java/doc/serialized-form.html
+++ b/java/doc/serialized-form.html
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_29) on Sun Dec 18 20:09:44 CST 2011 -->
+<!-- Generated by javadoc (build 1.6.0_31) on Wed Jun 06 03:10:33 CDT 2012 -->
 <TITLE>
 Serialized Form
 </TITLE>
 
-<META NAME="date" CONTENT="2011-12-18">
+<META NAME="date" CONTENT="2012-06-06">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index de6cacc..76f4f4f 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011-2012 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:
@@ -239,7 +239,17 @@
    * 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}.
+   * TJ#getScalingFactors} or by calling {@link #getScaledHeight}.  However,
+   * the buffer may also be larger than the dimensions of the JPEG image, in
+   * which case the <code>x</code>, <code>y</code>, and <code>pitch</code>
+   * parameters can be used to specify the region into which the JPEG image
+   * should be decompressed.
+   *
+   * @param x x offset (in pixels) of the region into which the JPEG image
+   * should be decompressed, relative to the start of <code>dstBuf</code>.
+   *
+   * @param y y offset (in pixels) of the region into which the JPEG image
+   * should be decompressed, relative to the start of <code>dstBuf</code>.
    *
    * @param desiredWidth desired width (in pixels) of the decompressed image.
    * If the desired image dimensions are smaller than the dimensions of the
@@ -252,7 +262,8 @@
    * @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:
+   * pad each line of the decompressed image to a 4-byte boundary or to
+   * decompress the JPEG image into a region of a larger image.  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
@@ -272,28 +283,65 @@
    *
    * @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 {
+  public void decompress(byte[] dstBuf, int x, int y, 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)
+    if(dstBuf == null || x < 0 || y < 0 || 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,
+    decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, pitch,
       desiredHeight, pixelFormat, flags);
   }
 
   /**
    * Decompress the JPEG source image associated with this decompressor
+   * instance and output a decompressed image to the given destination buffer.
+   *
+   * @param dstBuf see
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
+   *
+   * @param desiredWidth see
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
+   *
+   * @param pitch see
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
+   *
+   * @param desiredHeight see
+   * {@link #decompress(byte[], int, int, 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_*}
+   */
+  public void decompress(byte[] dstBuf, int desiredWidth, int pitch,
+    int desiredHeight, int pixelFormat, int flags)
+    throws Exception {
+    decompress(dstBuf, 0, 0, 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
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
    *
    * @param pitch see
-   * {@link #decompress(byte[], int, int, int, int, int)} for description
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
    *
    * @param desiredHeight see
-   * {@link #decompress(byte[], int, int, int, int, int)} for description
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)}
+   * for description
    *
    * @param pixelFormat pixel format of the decompressed image (one of
    * {@link TJ TJ.PF_*})
@@ -364,6 +412,68 @@
 
   /**
    * Decompress the JPEG source image associated with this decompressor
+   * instance and output a decompressed image to the given destination buffer.
+   *
+   * @param dstBuf buffer that will receive the decompressed image.  This
+   * buffer should normally be <code>stride * scaledHeight</code> pixels 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}.  However,
+   * the buffer may also be larger than the dimensions of the JPEG image, in
+   * which case the <code>x</code>, <code>y</code>, and <code>stride</code>
+   * parameters can be used to specify the region into which the JPEG image
+   * should be decompressed.
+   *
+   * @param x x offset (in pixels) of the region into which the JPEG image
+   * should be decompressed, relative to the start of <code>dstBuf</code>.
+   *
+   * @param y y offset (in pixels) of the region into which the JPEG image
+   * should be decompressed, relative to the start of <code>dstBuf</code>.
+   *
+   * @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 stride pixels per line of the destination image.  Normally, this
+   * should be set to <code>scaledWidth</code>, but you can use this to, for
+   * instance, decompress the JPEG image into a region of a larger image.
+   * 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</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(int[] dstBuf, int x, int y, int desiredWidth,
+    int stride, int desiredHeight, int pixelFormat, int flags)
+    throws Exception {
+    if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
+    if(dstBuf == null || x < 0 || y < 0 || desiredWidth < 0 || stride < 0
+      || desiredHeight < 0 || pixelFormat < 0 || pixelFormat >= TJ.NUMPF
+      || flags < 0)
+      throw new Exception("Invalid argument in decompress()");
+    decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, stride,
+      desiredHeight, pixelFormat, flags);
+  }
+
+  /**
+   * Decompress the JPEG source image associated with this decompressor
    * instance and output a decompressed image to the given
    * <code>BufferedImage</code> instance.
    *
@@ -444,10 +554,12 @@
    * decompressed image.
    *
    * @param desiredWidth see
-   * {@link #decompress(byte[], int, int, int, int, int)} for description
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)} for
+   * description
    *
    * @param desiredHeight see
-   * {@link #decompress(byte[], int, int, int, int, int)} for description
+   * {@link #decompress(byte[], int, int, int, int, int, int, int)} for
+   * description
    *
    * @param bufferedImageType the image type of the newly-created
    * <code>BufferedImage</code> instance (for instance,
@@ -498,8 +610,18 @@
     int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
     throws Exception;
 
+  private native void decompress(byte[] srcBuf, int size, byte[] dstBuf, int x,
+    int y, 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)
+    int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags)
+    throws Exception;
+
+  private native void decompress(byte[] srcBuf, int size, int[] dstBuf, int x,
+    int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat,
+    int flags)
     throws Exception;
 
   private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
diff --git a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h
index 6b67296..f798a77 100644
--- a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h
+++ b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h
@@ -42,6 +42,14 @@
 /*
  * Class:     org_libjpegturbo_turbojpeg_TJDecompressor
  * Method:    decompress
+ * Signature: ([BI[BIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII
+  (JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint, jint, jint, jint, jint, jint, jint);
+
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method:    decompress
  * Signature: ([BI[IIIIII)V
  */
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII
@@ -49,6 +57,14 @@
 
 /*
  * Class:     org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method:    decompress
+ * Signature: ([BI[IIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII
+  (JNIEnv *, jobject, jbyteArray, jint, jintArray, jint, jint, jint, jint, jint, jint, jint);
+
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJDecompressor
  * Method:    decompressToYUV
  * Signature: ([BI[BI)V
  */
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index 1ff9bba..3b9624a 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011-2012 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:
@@ -350,12 +350,12 @@
 	return;
 }
 
-JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII
 	(JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
-		jint width, jint pitch, jint height, jint pf, jint flags)
+		jint x, jint y, jint width, jint pitch, jint height, jint pf, jint flags)
 {
 	tjhandle handle=0;
-	jsize arraySize=0;
+	jsize arraySize=0, actualPitch;
 	unsigned char *jpegBuf=NULL, *dstBuf=NULL;
 
 	gethandle();
@@ -367,15 +367,68 @@
 
 	if((*env)->GetArrayLength(env, src)<jpegSize)
 		_throw("Source buffer is not large enough");
-	arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height;
+	actualPitch=(pitch==0)? width*tjPixelSize[pf]:pitch;
+	arraySize=(y+height)*actualPitch + x*tjPixelSize[pf];
 	if((*env)->GetArrayLength(env, dst)<arraySize)
 		_throw("Destination buffer is not large enough");
 
 	bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
 	bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
 
-	if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width,
-		pitch, height, pf, flags)==-1)
+	if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
+		&dstBuf[y*actualPitch + x*tjPixelSize[pf]], width, pitch, height, pf,
+		flags)==-1)
+	{
+		(*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
+		(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
+		dstBuf=jpegBuf=NULL;
+		_throw(tjGetErrorStr());
+	}
+
+	bailout:
+	if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
+	if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
+	return;
+}
+
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII
+	(JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
+		jint width, jint pitch, jint height, jint pf, jint flags)
+{
+	Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII
+		(env, obj, src, jpegSize, dst, 0, 0, width, pitch, height, pf, flags);
+}
+
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII
+	(JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
+		jint x, jint y, jint width, jint stride, jint height, jint pf, jint flags)
+{
+	tjhandle handle=0;
+	jsize arraySize=0, actualStride;
+	unsigned char *jpegBuf=NULL, *dstBuf=NULL;
+
+	gethandle();
+
+	if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF)
+		_throw("Invalid argument in decompress()");
+	if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
+		_throw("Mismatch between Java and C API");
+	if(tjPixelSize[pf]!=sizeof(jint))
+		_throw("Pixel format must be 32-bit when decompressing to an integer buffer.");
+
+	if((*env)->GetArrayLength(env, src)<jpegSize)
+		_throw("Source buffer is not large enough");
+	actualStride=(stride==0)? width:stride;
+	arraySize=(y+height)*actualStride + x;
+	if((*env)->GetArrayLength(env, dst)<arraySize)
+		_throw("Destination buffer is not large enough");
+
+	bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
+	bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
+
+	if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
+		&dstBuf[(y*actualStride + x)*sizeof(int)], width, stride*sizeof(jint),
+		height, pf, flags)==-1)
 	{
 		(*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
 		(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
@@ -391,43 +444,11 @@
 
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII
 	(JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
-		jint width, jint pitch, jint height, jint pf, jint flags)
+		jint width, jint stride, jint height, jint pf, jint flags)
 {
-	tjhandle handle=0;
-	jsize arraySize=0;
-	unsigned char *jpegBuf=NULL, *dstBuf=NULL;
-
-	gethandle();
-
-	if(pf<0 || pf>=org_libjpegturbo_turbojpeg_TJ_NUMPF)
-		_throw("Invalid argument in decompress()");
-	if(org_libjpegturbo_turbojpeg_TJ_NUMPF!=TJ_NUMPF)
-		_throw("Mismatch between Java and C API");
-	if(tjPixelSize[pf]!=sizeof(jint))
-		_throw("Pixel format must be 32-bit when decompressing to an integer buffer.");
-
-	if((*env)->GetArrayLength(env, src)<jpegSize)
-		_throw("Source buffer is not large enough");
-	arraySize=(pitch==0)? width*height:pitch*height;
-	if((*env)->GetArrayLength(env, dst)<arraySize)
-		_throw("Destination buffer is not large enough");
-
-	bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
-	bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
-
-	if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width,
-		pitch*sizeof(jint), height, pf, flags)==-1)
-	{
-		(*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
-		(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
-		dstBuf=jpegBuf=NULL;
-		_throw(tjGetErrorStr());
-	}
-
-	bailout:
-	if(dstBuf) (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
-	if(jpegBuf) (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
-	return;
+	Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII
+		(env, obj, src, jpegSize, dst, 0, 0, width, stride, height, pf, flags);
+	
 }
 
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV