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.)

This commit is contained in:
DRC
2012-06-06 08:41:06 +00:00
parent 8aab7a1dad
commit 448d12d298
23 changed files with 403 additions and 103 deletions

View File

@@ -34,6 +34,9 @@ calling conventions.
images (specifically, images in which the component count was erroneously set images (specifically, images in which the component count was erroneously set
to a large value) would cause libjpeg-turbo to segfault. 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 1.2.0
===== =====

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
All Classes All Classes
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
All Classes All Classes
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Constant Field Values Constant Field Values
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Deprecated List Deprecated List
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
API Help API Help
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Index Index
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="./stylesheet.css" TITLE="Style">
@@ -129,6 +129,10 @@ Method in interface org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbo
<A NAME="_D_"><!-- --></A><H2> <A NAME="_D_"><!-- --></A><H2>
<B>D</B></H2> <B>D</B></H2>
<DL> <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> - <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> 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 <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
Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</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 <DD>Decompress the JPEG source image associated with this decompressor
instance and return a buffer containing the decompressed image. 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> - <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> 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 <DD>Decompress the JPEG source image associated with this decompressor

View File

@@ -2,7 +2,7 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Generated Documentation (Untitled) Generated Documentation (Untitled)
</TITLE> </TITLE>

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJ TJ
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJCompressor TJCompressor
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJCustomFilter TJCustomFilter
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJDecompressor TJDecompressor
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
@@ -236,6 +236,38 @@ TurboJPEG decompressor
int&nbsp;pixelFormat, int&nbsp;pixelFormat,
int&nbsp;flags)</CODE> 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(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> <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decompress the JPEG source image associated with this decompressor &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> instance and output a decompressed image to the given destination buffer.</TD>
@@ -688,10 +720,12 @@ public int <B>getScaledHeight</B>(int&nbsp;desiredWidth,
</DL> </DL>
<HR> <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> decompress</H3>
<PRE> <PRE>
public void <B>decompress</B>(byte[]&nbsp;dstBuf, public void <B>decompress</B>(byte[]&nbsp;dstBuf,
int&nbsp;x,
int&nbsp;y,
int&nbsp;desiredWidth, int&nbsp;desiredWidth,
int&nbsp;pitch, int&nbsp;pitch,
int&nbsp;desiredHeight, int&nbsp;desiredHeight,
@@ -707,7 +741,13 @@ public void <B>decompress</B>(byte[]&nbsp;dstBuf,
buffer should normally be <code>pitch * scaledHeight</code> bytes in size, buffer should normally be <code>pitch * scaledHeight</code> bytes in size,
where <code>scaledHeight</code> can be determined by calling <code> 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) 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 If the desired image dimensions are smaller than the dimensions of the
JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG
decompressor to generate the largest possible image that will fit within decompressor to generate the largest possible image that will fit within
@@ -716,7 +756,8 @@ public void <B>decompress</B>(byte[]&nbsp;dstBuf,
considered when determining the scaled image size.)<DD><CODE>pitch</CODE> - bytes per line of the destination image. Normally, this 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 should be set to <code>scaledWidth * TJ.pixelSize(pixelFormat)</code> if
the decompressed image is unpadded, but you can use this to, for instance, 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> <code>scaledWidth</code> can be determined by calling <code>
scalingFactor.<A HREF="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#getScaled(int)"><CODE>getScaled</CODE></A>(jpegWidth) 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 </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 @@ public void <B>decompress</B>(byte[]&nbsp;dstBuf,
</DL> </DL>
<HR> <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> <A NAME="decompress(int, int, int, int, int)"><!-- --></A><H3>
decompress</H3> decompress</H3>
<PRE> <PRE>
@@ -750,9 +822,12 @@ public byte[] <B>decompress</B>(int&nbsp;desiredWidth,
<P> <P>
<DD><DL> <DD><DL>
<DT><B>Parameters:</B><DD><CODE>desiredWidth</CODE> - see <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, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A>
<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 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>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>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> <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>Returns:</B><DD>a buffer containing the decompressed image
<DT><B>Throws:</B> <DT><B>Throws:</B>
@@ -806,6 +881,59 @@ public byte[] <B>decompressToYUV</B>(int&nbsp;flags)
</DL> </DL>
<HR> <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> <A NAME="decompress(java.awt.image.BufferedImage, int)"><!-- --></A><H3>
decompress</H3> decompress</H3>
<PRE> <PRE>
@@ -841,8 +969,10 @@ public java.awt.image.BufferedImage <B>decompress</B>(int&nbsp;desiredWidth,
<P> <P>
<DD><DL> <DD><DL>
<DT><B>Parameters:</B><DD><CODE>desiredWidth</CODE> - see <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, int, int)"><CODE>decompress(byte[], int, int, int, int, int, int, int)</CODE></A> for
<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 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</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> <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 <DT><B>Returns:</B><DD>a <code>BufferedImage</code> instance containing the

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJScalingFactor TJScalingFactor
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJTransform TJTransform
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
TJTransformer TJTransformer
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
@@ -205,7 +205,7 @@ TurboJPEG lossless transformer
<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> <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>
<TR BGCOLOR="white" CLASS="TableRowColor"> <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> </TR>
</TABLE> </TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
org.libjpegturbo.turbojpeg org.libjpegturbo.turbojpeg
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
org.libjpegturbo.turbojpeg org.libjpegturbo.turbojpeg
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
org.libjpegturbo.turbojpeg Class Hierarchy org.libjpegturbo.turbojpeg Class Hierarchy
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Class Hierarchy Class Hierarchy
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -2,12 +2,12 @@
<!--NewPage--> <!--NewPage-->
<HTML> <HTML>
<HEAD> <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> <TITLE>
Serialized Form Serialized Form
</TITLE> </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"> <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

View File

@@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -239,7 +239,17 @@ public class TJDecompressor {
* where <code>scaledHeight</code> can be determined by calling <code> * where <code>scaledHeight</code> can be determined by calling <code>
* scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight) * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
* </code> with one of the scaling factors returned from {@link * </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. * @param desiredWidth desired width (in pixels) of the decompressed image.
* If the desired image dimensions are smaller than the dimensions of the * If the desired image dimensions are smaller than the dimensions of the
@@ -252,7 +262,8 @@ public class TJDecompressor {
* @param pitch bytes per line of the destination image. Normally, this * @param pitch bytes per line of the destination image. Normally, this
* should be set to <code>scaledWidth * TJ.pixelSize(pixelFormat)</code> if * should be set to <code>scaledWidth * TJ.pixelSize(pixelFormat)</code> if
* the decompressed image is unpadded, but you can use this to, for instance, * 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> * <code>scaledWidth</code> can be determined by calling <code>
* scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth) * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
* </code> or by calling {@link #getScaledWidth}. Setting this parameter to * </code> or by calling {@link #getScaledWidth}. Setting this parameter to
@@ -272,28 +283,65 @@ public class TJDecompressor {
* *
* @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*} * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
*/ */
public void decompress(byte[] dstBuf, int desiredWidth, int pitch, public void decompress(byte[] dstBuf, int x, int y, int desiredWidth,
int desiredHeight, int pixelFormat, int flags) throws Exception { int pitch, int desiredHeight, int pixelFormat, int flags)
throws Exception {
if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR); if(jpegBuf == null) throw new Exception(NO_ASSOC_ERROR);
if(dstBuf == null || desiredWidth < 0 || pitch < 0 || desiredHeight < 0 if(dstBuf == null || x < 0 || y < 0 || desiredWidth < 0 || pitch < 0
|| pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0) || desiredHeight < 0 || pixelFormat < 0 || pixelFormat >= TJ.NUMPF
|| flags < 0)
throw new Exception("Invalid argument in decompress()"); throw new Exception("Invalid argument in decompress()");
decompress(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pitch, decompress(jpegBuf, jpegBufSize, dstBuf, x, y, desiredWidth, pitch,
desiredHeight, pixelFormat, flags); 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 * Decompress the JPEG source image associated with this decompressor
* instance and return a buffer containing the decompressed image. * instance and return a buffer containing the decompressed image.
* *
* @param desiredWidth see * @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 * @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 * @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 * @param pixelFormat pixel format of the decompressed image (one of
* {@link TJ TJ.PF_*}) * {@link TJ TJ.PF_*})
@@ -362,6 +410,68 @@ public class TJDecompressor {
return buf; return buf;
} }
/**
* 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 * Decompress the JPEG source image associated with this decompressor
* instance and output a decompressed image to the given * instance and output a decompressed image to the given
@@ -444,10 +554,12 @@ public class TJDecompressor {
* decompressed image. * decompressed image.
* *
* @param desiredWidth see * @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 * @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 * @param bufferedImageType the image type of the newly-created
* <code>BufferedImage</code> instance (for instance, * <code>BufferedImage</code> instance (for instance,
@@ -498,8 +610,18 @@ public class TJDecompressor {
int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags) int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
throws Exception; 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, 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; throws Exception;
private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf, private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,

View File

@@ -39,6 +39,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII
(JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint, jint, jint, jint, jint); (JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint, jint, jint, jint, jint);
/*
* 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 * Class: org_libjpegturbo_turbojpeg_TJDecompressor
* Method: decompress * Method: decompress
@@ -47,6 +55,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII
(JNIEnv *, jobject, jbyteArray, jint, jintArray, jint, jint, jint, jint, jint); (JNIEnv *, jobject, jbyteArray, jint, jintArray, jint, jint, jint, jint, jint);
/*
* 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 * Class: org_libjpegturbo_turbojpeg_TJDecompressor
* Method: decompressToYUV * Method: decompressToYUV

View File

@@ -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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -350,12 +350,12 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
return; 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, (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; tjhandle handle=0;
jsize arraySize=0; jsize arraySize=0, actualPitch;
unsigned char *jpegBuf=NULL, *dstBuf=NULL; unsigned char *jpegBuf=NULL, *dstBuf=NULL;
gethandle(); gethandle();
@@ -367,15 +367,68 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
if((*env)->GetArrayLength(env, src)<jpegSize) if((*env)->GetArrayLength(env, src)<jpegSize)
_throw("Source buffer is not large enough"); _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) if((*env)->GetArrayLength(env, dst)<arraySize)
_throw("Destination buffer is not large enough"); _throw("Destination buffer is not large enough");
bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0)); bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0)); bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, width, if(tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
pitch, height, pf, flags)==-1) &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, dst, dstBuf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0); (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
@@ -391,43 +444,11 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII
(JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst, (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; Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII
jsize arraySize=0; (env, obj, src, jpegSize, dst, 0, 0, width, stride, height, pf, flags);
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;
} }
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV