test: testclean all
if WITH_TURBOJPEG
-#if WITH_JAVA
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -bi
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -noyuvpad
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi
-# $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi -noyuvpad
-#endif
+if WITH_JAVA
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -bi
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -noyuvpad
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi
+ $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi -noyuvpad
+endif
./tjunittest
./tjunittest -alloc
./tjunittest -yuv
private static final String[] pixFormatStr = {
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
- "RGBA", "BGRA", "ABGR", "ARGB"
+ "RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
};
private static final int[] alphaOffset = {
- -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0
+ -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
};
private static final int[] _3byteFormats = {
BufferedImage.TYPE_3BYTE_BGR
};
private static final int[] _4byteFormats = {
- TJ.PF_RGBX, TJ.PF_BGRX, TJ.PF_XBGR, TJ.PF_XRGB
+ TJ.PF_RGBX, TJ.PF_BGRX, TJ.PF_XBGR, TJ.PF_XRGB, TJ.PF_CMYK
};
private static final int[] _4byteFormatsBI = {
BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_INT_RGB,
int ps = TJ.getPixelSize(pf);
int index, row, col, halfway = 16;
- Arrays.fill(buf, (byte)0);
if (pf == TJ.PF_GRAY) {
+ Arrays.fill(buf, (byte)0);
for (row = 0; row < h; row++) {
for (col = 0; col < w; col++) {
if ((flags & TJ.FLAG_BOTTOMUP) != 0)
}
return;
}
+ if (pf == TJ.PF_CMYK) {
+ Arrays.fill(buf, (byte)255);
+ for (row = 0; row < h; row++) {
+ for (col = 0; col < w; col++) {
+ if ((flags & TJ.FLAG_BOTTOMUP) != 0)
+ index = (h - row - 1) * w + col;
+ else
+ index = row * w + col;
+ if (((row / 8) + (col / 8)) % 2 == 0) {
+ if (row >= halfway) buf[index * ps + 3] = 0;
+ } else {
+ buf[index * ps + 2] = 0;
+ if (row < halfway)
+ buf[index * ps + 1] = 0;
+ }
+ }
+ }
+ return;
+ }
+
+ Arrays.fill(buf, (byte)0);
for (row = 0; row < h; row++) {
for (col = 0; col < w; col++) {
if ((flags & TJ.FLAG_BOTTOMUP) != 0)
int blockSize = 8 * sf.getNum() / sf.getDenom();
try {
+
+ if (pf == TJ.PF_CMYK) {
+ for (row = 0; row < h; row++) {
+ for (col = 0; col < w; col++) {
+ if ((flags & TJ.FLAG_BOTTOMUP) != 0)
+ index = (h - row - 1) * w + col;
+ else
+ index = row * w + col;
+ byte c = buf[index * ps];
+ byte m = buf[index * ps + 1];
+ byte y = buf[index * ps + 2];
+ byte k = buf[index * ps + 3];
+ checkVal255(row, col, c, "C");
+ if (((row / blockSize) + (col / blockSize)) % 2 == 0) {
+ checkVal255(row, col, m, "M");
+ checkVal255(row, col, y, "Y");
+ if (row < halfway)
+ checkVal255(row, col, k, "K");
+ else
+ checkVal0(row, col, k, "K");
+ } else {
+ checkVal0(row, col, y, "Y");
+ checkVal255(row, col, k, "K");
+ if (row < halfway)
+ checkVal0(row, col, m, "M");
+ else
+ checkVal255(row, col, m, "M");
+ }
+ }
+ }
+ return 1;
+ }
+
for (row = 0; row < halfway; row++) {
for (col = 0; col < w; col++) {
if ((flags & TJ.FLAG_BOTTOMUP) != 0)
if (retval == 0) {
for (row = 0; row < h; row++) {
for (col = 0; col < w; col++) {
- int r = buf[pitch * row + col * ps + roffset];
- int g = buf[pitch * row + col * ps + goffset];
- int b = buf[pitch * row + col * ps + boffset];
- if (r < 0) r += 256;
- if (g < 0) g += 256;
- if (b < 0) b += 256;
- System.out.format("%3d/%3d/%3d ", r, g, b);
+ if (pf == TJ.PF_CMYK) {
+ int c = buf[pitch * row + col * ps];
+ int m = buf[pitch * row + col * ps + 1];
+ int y = buf[pitch * row + col * ps + 2];
+ int k = buf[pitch * row + col * ps + 3];
+ if (c < 0) c += 256;
+ if (m < 0) m += 256;
+ if (y < 0) y += 256;
+ if (k < 0) k += 256;
+ System.out.format("%3d/%3d/%3d/%3d ", c, m, y, k);
+ } else {
+ int r = buf[pitch * row + col * ps + roffset];
+ int g = buf[pitch * row + col * ps + goffset];
+ int b = buf[pitch * row + col * ps + boffset];
+ if (r < 0) r += 256;
+ if (g < 0) g += 256;
+ if (b < 0) b += 256;
+ System.out.format("%3d/%3d/%3d ", r, g, b);
+ }
}
System.out.print("\n");
}
tjd = new TJDecompressor();
for (int pf : formats) {
+ if (pf < 0) continue;
for (int i = 0; i < 2; i++) {
int flags = 0;
if (subsamp == TJ.SAMP_422 || subsamp == TJ.SAMP_420 ||
testName = "javabitest";
}
}
- if (doyuv) yuv = YUVENCODE;
+ if (doyuv) {
+ yuv = YUVENCODE;
+ _4byteFormats[4] = -1;
+ }
doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_444,
testName);
doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_444,
doTest(39, 41, bi ? onlyGrayBI : onlyGray, TJ.SAMP_GRAY, testName);
doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_GRAY,
testName);
+ _4byteFormats[4] = -1;
doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_GRAY,
testName);
if (!doyuv && !bi)
<TH ALIGN="left" COLSPAN="3">org.libjpegturbo.turbojpeg.<A HREF="org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.CS_CMYK"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#CS_CMYK">CS_CMYK</A></CODE></TD>
+<TD ALIGN="right"><CODE>3</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.CS_GRAY"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#CS_GRAY">CS_GRAY</A></CODE></TD>
+<TD ALIGN="right"><CODE>2</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.CS_RGB"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#CS_RGB">CS_RGB</A></CODE></TD>
+<TD ALIGN="right"><CODE>0</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.CS_YCbCr"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#CS_YCbCr">CS_YCbCr</A></CODE></TD>
+<TD ALIGN="right"><CODE>1</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.CS_YCCK"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#CS_YCCK">CS_YCCK</A></CODE></TD>
+<TD ALIGN="right"><CODE>4</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="org.libjpegturbo.turbojpeg.TJ.FLAG_ACCURATEDCT"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public static final int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#FLAG_ACCURATEDCT">FLAG_ACCURATEDCT</A></CODE></TD>
<TD ALIGN="right"><CODE>128</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.NUMCS"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#NUMCS">NUMCS</A></CODE></TD>
+<TD ALIGN="right"><CODE>5</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="org.libjpegturbo.turbojpeg.TJ.NUMPF"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public static final int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#NUMPF">NUMPF</A></CODE></TD>
-<TD ALIGN="right"><CODE>11</CODE></TD>
+<TD ALIGN="right"><CODE>12</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="org.libjpegturbo.turbojpeg.TJ.NUMSAMP"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<TD ALIGN="right"><CODE>3</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
+<A NAME="org.libjpegturbo.turbojpeg.TJ.PF_CMYK"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
+<CODE>public static final int</CODE></FONT></TD>
+<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#PF_CMYK">PF_CMYK</A></CODE></TD>
+<TD ALIGN="right"><CODE>11</CODE></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="org.libjpegturbo.turbojpeg.TJ.PF_GRAY"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public static final int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="org/libjpegturbo/turbojpeg/TJ.html#PF_GRAY">PF_GRAY</A></CODE></TD>
Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</A>
<DD>Compress the uncompressed source image stored in <code>srcImage</code>
and return a buffer containing a JPEG image.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#CS_CMYK"><B>CS_CMYK</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>CMYK colorspace.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#CS_GRAY"><B>CS_GRAY</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>Grayscale colorspace.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#CS_RGB"><B>CS_RGB</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>RGB colorspace.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#CS_YCbCr"><B>CS_YCbCr</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>YCbCr colorspace.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#CS_YCCK"><B>CS_YCCK</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>YCCK colorspace.
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJCustomFilter.html#customFilter(java.nio.ShortBuffer, java.awt.Rectangle, java.awt.Rectangle, int, int, org.libjpegturbo.turbojpeg.TJTransform)"><B>customFilter(ShortBuffer, Rectangle, Rectangle, int, int, TJTransform)</B></A> -
Method in interface org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJCustomFilter.html" title="interface in org.libjpegturbo.turbojpeg">TJCustomFilter</A>
<DD>A callback function that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
- JPEG file.
+ JPEG image.
</DL>
<HR>
<A NAME="_D_"><!-- --></A><H2>
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBufSize"><B>jpegBufSize</B></A> -
Variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
<DD>
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegColorspace"><B>jpegColorspace</B></A> -
+Variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
+<DD>
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegHeight"><B>jpegHeight</B></A> -
Variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
<DD>
<A NAME="_N_"><!-- --></A><H2>
<B>N</B></H2>
<DL>
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#NUMCS"><B>NUMCS</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>The number of JPEG colorspaces
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJTransform.html#NUMOP"><B>NUMOP</B></A> -
Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJTransform.html" title="class in org.libjpegturbo.turbojpeg">TJTransform</A>
<DD>The number of lossless transform operations
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#PF_BGRX"><B>PF_BGRX</B></A> -
Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
<DD>BGRX pixel format.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#PF_CMYK"><B>PF_CMYK</B></A> -
+Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD>CMYK pixel format.
<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#PF_GRAY"><B>PF_GRAY</B></A> -
Static variable in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
<DD>Grayscale pixel format.
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_CMYK">CS_CMYK</A></B></CODE>
+
+<BR>
+ CMYK colorspace.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_GRAY">CS_GRAY</A></B></CODE>
+
+<BR>
+ Grayscale colorspace.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_RGB">CS_RGB</A></B></CODE>
+
+<BR>
+ RGB colorspace.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCbCr">CS_YCbCr</A></B></CODE>
+
+<BR>
+ YCbCr colorspace.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCCK">CS_YCCK</A></B></CODE>
+
+<BR>
+ YCCK colorspace.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#FLAG_ACCURATEDCT">FLAG_ACCURATEDCT</A></B></CODE>
<BR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#NUMCS">NUMCS</A></B></CODE>
+
+<BR>
+ The number of JPEG colorspaces</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#NUMPF">NUMPF</A></B></CODE>
<BR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#PF_CMYK">PF_CMYK</A></B></CODE>
+
+<BR>
+ CMYK pixel format.</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#PF_GRAY">PF_GRAY</A></B></CODE>
<BR>
</DL>
<HR>
+<A NAME="PF_CMYK"><!-- --></A><H3>
+PF_CMYK</H3>
+<PRE>
+public static final int <B>PF_CMYK</B></PRE>
+<DL>
+<DD>CMYK pixel format. Unlike RGB, which is a display colorspace,
+ CMYK (Cyan/Magenta/Yellow/Key) is a print colorspace in which the
+ value of each color component corresponds to the amount of cyan, magenta,
+ yellow, or black ink that is applied to a white background. In order to
+ convert between CMYK and RGB, it is necessary to use a color management
+ system (CMS.) A CMS will attempt to map colors within the printer's gamut
+ to perceptually similar colors in the display's gamut and vice versa, but
+ the mapping is typically not 1:1 or reversible, nor can it be defined with
+ a simple formula. Thus, such a conversion is out of scope for a codec
+ library. However, the TurboJPEG API allows for compressing CMYK pixels
+ into a YCCK JPEG image (see <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#CS_YCCK"><CODE>CS_YCCK</CODE></A>) and decompressing YCCK JPEG
+ images into CMYK pixels.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PF_CMYK">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="NUMCS"><!-- --></A><H3>
+NUMCS</H3>
+<PRE>
+public static final int <B>NUMCS</B></PRE>
+<DL>
+<DD>The number of JPEG colorspaces
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.NUMCS">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="CS_RGB"><!-- --></A><H3>
+CS_RGB</H3>
+<PRE>
+public static final int <B>CS_RGB</B></PRE>
+<DL>
+<DD>RGB colorspace. When compressing the JPEG image, the R, G, and B
+ components in the source image are reordered into image planes, but no
+ colorspace conversion or subsampling is performed. RGB JPEG images can be
+ decompressed to any of the extended RGB pixel formats or grayscale, but
+ they cannot be decompressed to YUV images.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.CS_RGB">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="CS_YCbCr"><!-- --></A><H3>
+CS_YCbCr</H3>
+<PRE>
+public static final int <B>CS_YCbCr</B></PRE>
+<DL>
+<DD>YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
+ mathematical transformation of RGB designed solely for storage and
+ transmission. YCbCr images must be converted to RGB before they can
+ actually be displayed. In the YCbCr colorspace, the Y (luminance)
+ component represents the black & white portion of the original image, and
+ the Cb and Cr (chrominance) components represent the color portion of the
+ original image. Originally, the analog equivalent of this transformation
+ allowed the same signal to drive both black & white and color televisions,
+ but JPEG images use YCbCr primarily because it allows the color data to be
+ optionally subsampled for the purposes of reducing bandwidth or disk
+ space. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
+ can be compressed from and decompressed to any of the extended RGB pixel
+ formats or grayscale, or they can be decompressed to YUV planar images.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.CS_YCbCr">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="CS_GRAY"><!-- --></A><H3>
+CS_GRAY</H3>
+<PRE>
+public static final int <B>CS_GRAY</B></PRE>
+<DL>
+<DD>Grayscale colorspace. The JPEG image retains only the luminance data (Y
+ component), and any color data from the source image is discarded.
+ Grayscale JPEG images can be compressed from and decompressed to any of
+ the extended RGB pixel formats or grayscale, or they can be decompressed
+ to YUV planar images.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.CS_GRAY">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="CS_CMYK"><!-- --></A><H3>
+CS_CMYK</H3>
+<PRE>
+public static final int <B>CS_CMYK</B></PRE>
+<DL>
+<DD>CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
+ components in the source image are reordered into image planes, but no
+ colorspace conversion or subsampling is performed. CMYK JPEG images can
+ only be decompressed to CMYK pixels.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.CS_CMYK">Constant Field Values</A></DL>
+</DL>
+<HR>
+
+<A NAME="CS_YCCK"><!-- --></A><H3>
+CS_YCCK</H3>
+<PRE>
+public static final int <B>CS_YCCK</B></PRE>
+<DL>
+<DD>YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
+ rather a mathematical transformation of CMYK designed solely for storage
+ and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+ reversibly transformed into YCCK, and as with YCbCr, the chrominance
+ components in the YCCK pixels can be subsampled without incurring major
+ perceptual loss. YCCK JPEG images can only be compressed from and
+ decompressed to CMYK pixels.
+<P>
+<DL>
+<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.CS_YCCK">Constant Field Values</A></DL>
+</DL>
+<HR>
+
<A NAME="FLAG_BOTTOMUP"><!-- --></A><H3>
FLAG_BOTTOMUP</H3>
<PRE>
<DD>Associate an uncompressed source image with this compressor instance.
<P>
<DD><DL>
-<DT><B>Parameters:</B><DD><CODE>srcImage</CODE> - image buffer containing RGB or grayscale pixels to be
- compressed<DD><CODE>x</CODE> - x offset (in pixels) of the region from which the JPEG image
+<DT><B>Parameters:</B><DD><CODE>srcImage</CODE> - image buffer containing RGB, grayscale, or CMYK pixels to
+ be compressed<DD><CODE>x</CODE> - x offset (in pixels) of the region from which the JPEG image
should be compressed, relative to the start of <code>srcImage</code>.<DD><CODE>y</CODE> - y offset (in pixels) of the region from which the JPEG image
should be compressed, relative to the start of <code>srcImage</code>.<DD><CODE>width</CODE> - width (in pixels) of the region in the source image from
which the JPEG image should be compressed.<DD><CODE>pitch</CODE> - bytes per line of the source image. Normally, this should be
<BR>
A callback function that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
- JPEG file.</TD>
+ JPEG image.</TD>
</TR>
</TABLE>
<DL>
<DD>A callback function that can be used to modify the DCT coefficients after
they are losslessly transformed but before they are transcoded to a new
- JPEG file. This allows for custom filters or other transformations to be
+ JPEG image. This allows for custom filters or other transformations to be
applied in the frequency domain.
<P>
<DD><DL>
<CODE>protected int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBufSize">jpegBufSize</A></B></CODE>
+<BR>
+ </TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>protected int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegColorspace">jpegColorspace</A></B></CODE>
+
<BR>
</TD>
</TR>
<DL>
</DL>
</DL>
+<HR>
+
+<A NAME="jpegColorspace"><!-- --></A><H3>
+jpegColorspace</H3>
+<PRE>
+protected int <B>jpegColorspace</B></PRE>
+<DL>
+<DL>
+</DL>
+</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<TH ALIGN="left"><B>Fields 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#handle">handle</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBuf">jpegBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBufSize">jpegBufSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegHeight">jpegHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegSubsamp">jpegSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegWidth">jpegWidth</A></CODE></TD>
+<TD><CODE><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#handle">handle</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBuf">jpegBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegBufSize">jpegBufSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegColorspace">jpegColorspace</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegHeight">jpegHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegSubsamp">jpegSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#jpegWidth">jpegWidth</A></CODE></TD>
</TR>
</TABLE>
/**
* The number of pixel formats
*/
- public static final int NUMPF = 11;
+ public static final int NUMPF = 12;
/**
* RGB pixel format. The red, green, and blue components in the image are
* stored in 3-byte pixels in the order R, G, B from lowest to highest byte
* interpreted as an opaque alpha channel.
*/
public static final int PF_ARGB = 10;
+ /**
+ * CMYK pixel format. Unlike RGB, which is a display colorspace,
+ * CMYK (Cyan/Magenta/Yellow/Key) is a print colorspace in which the
+ * value of each color component corresponds to the amount of cyan, magenta,
+ * yellow, or black ink that is applied to a white background. In order to
+ * convert between CMYK and RGB, it is necessary to use a color management
+ * system (CMS.) A CMS will attempt to map colors within the printer's gamut
+ * to perceptually similar colors in the display's gamut and vice versa, but
+ * the mapping is typically not 1:1 or reversible, nor can it be defined with
+ * a simple formula. Thus, such a conversion is out of scope for a codec
+ * library. However, the TurboJPEG API allows for compressing CMYK pixels
+ * into a YCCK JPEG image (see {@link #CS_YCCK}) and decompressing YCCK JPEG
+ * images into CMYK pixels.
+ */
+ public static final int PF_CMYK = 11;
/**
}
private static final int[] pixelSize = {
- 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4
+ 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
};
}
private static final int[] redOffset = {
- 0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1
+ 0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1, -1
};
}
private static final int[] greenOffset = {
- 1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2
+ 1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1
};
}
private static final int[] blueOffset = {
- 2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3
+ 2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1
};
+ /**
+ * The number of JPEG colorspaces
+ */
+ public static final int NUMCS = 5;
+ /**
+ * RGB colorspace. When compressing the JPEG image, the R, G, and B
+ * components in the source image are reordered into image planes, but no
+ * colorspace conversion or subsampling is performed. RGB JPEG images can be
+ * decompressed to any of the extended RGB pixel formats or grayscale, but
+ * they cannot be decompressed to YUV images.
+ */
+ public static final int CS_RGB = 0;
+ /**
+ * YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
+ * mathematical transformation of RGB designed solely for storage and
+ * transmission. YCbCr images must be converted to RGB before they can
+ * actually be displayed. In the YCbCr colorspace, the Y (luminance)
+ * component represents the black & white portion of the original image, and
+ * the Cb and Cr (chrominance) components represent the color portion of the
+ * original image. Originally, the analog equivalent of this transformation
+ * allowed the same signal to drive both black & white and color televisions,
+ * but JPEG images use YCbCr primarily because it allows the color data to be
+ * optionally subsampled for the purposes of reducing bandwidth or disk
+ * space. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
+ * can be compressed from and decompressed to any of the extended RGB pixel
+ * formats or grayscale, or they can be decompressed to YUV planar images.
+ */
+ public static final int CS_YCbCr = 1;
+ /**
+ * Grayscale colorspace. The JPEG image retains only the luminance data (Y
+ * component), and any color data from the source image is discarded.
+ * Grayscale JPEG images can be compressed from and decompressed to any of
+ * the extended RGB pixel formats or grayscale, or they can be decompressed
+ * to YUV planar images.
+ */
+ public static final int CS_GRAY = 2;
+ /**
+ * CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
+ * components in the source image are reordered into image planes, but no
+ * colorspace conversion or subsampling is performed. CMYK JPEG images can
+ * only be decompressed to CMYK pixels.
+ */
+ public static final int CS_CMYK = 3;
+ /**
+ * YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
+ * rather a mathematical transformation of CMYK designed solely for storage
+ * and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+ * reversibly transformed into YCCK, and as with YCbCr, the chrominance
+ * components in the YCCK pixels can be subsampled without incurring major
+ * perceptual loss. YCCK JPEG images can only be compressed from and
+ * decompressed to CMYK pixels.
+ */
+ public static final int CS_YCCK = 4;
+
+
/**
* The uncompressed source/destination image is stored in bottom-up (Windows,
* OpenGL) order, not top-down (X11) order.
/**
* Associate an uncompressed source image with this compressor instance.
*
- * @param srcImage image buffer containing RGB or grayscale pixels to be
- * compressed
+ * @param srcImage image buffer containing RGB, grayscale, or CMYK pixels to
+ * be compressed
*
* @param x x offset (in pixels) of the region from which the JPEG image
* should be compressed, relative to the start of <code>srcImage</code>.
/**
* A callback function that can be used to modify the DCT coefficients after
* they are losslessly transformed but before they are transcoded to a new
- * JPEG file. This allows for custom filters or other transformations to be
+ * JPEG image. This allows for custom filters or other transformations to be
* applied in the frequency domain.
*
* @param coeffBuffer a buffer containing transformed DCT coefficients.
protected int jpegWidth = 0;
protected int jpegHeight = 0;
protected int jpegSubsamp = -1;
+ protected int jpegColorspace = -1;
private ByteOrder byteOrder = null;
};
extern "C" {
#endif
#undef org_libjpegturbo_turbojpeg_TJ_NUMSAMP
-#define org_libjpegturbo_turbojpeg_TJ_NUMSAMP 5L
+#define org_libjpegturbo_turbojpeg_TJ_NUMSAMP 6L
#undef org_libjpegturbo_turbojpeg_TJ_SAMP_444
#define org_libjpegturbo_turbojpeg_TJ_SAMP_444 0L
#undef org_libjpegturbo_turbojpeg_TJ_SAMP_422
#define org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY 3L
#undef org_libjpegturbo_turbojpeg_TJ_SAMP_440
#define org_libjpegturbo_turbojpeg_TJ_SAMP_440 4L
+#undef org_libjpegturbo_turbojpeg_TJ_SAMP_411
+#define org_libjpegturbo_turbojpeg_TJ_SAMP_411 5L
#undef org_libjpegturbo_turbojpeg_TJ_NUMPF
-#define org_libjpegturbo_turbojpeg_TJ_NUMPF 11L
+#define org_libjpegturbo_turbojpeg_TJ_NUMPF 12L
#undef org_libjpegturbo_turbojpeg_TJ_PF_RGB
#define org_libjpegturbo_turbojpeg_TJ_PF_RGB 0L
#undef org_libjpegturbo_turbojpeg_TJ_PF_BGR
#define org_libjpegturbo_turbojpeg_TJ_PF_ABGR 9L
#undef org_libjpegturbo_turbojpeg_TJ_PF_ARGB
#define org_libjpegturbo_turbojpeg_TJ_PF_ARGB 10L
+#undef org_libjpegturbo_turbojpeg_TJ_PF_CMYK
+#define org_libjpegturbo_turbojpeg_TJ_PF_CMYK 11L
+#undef org_libjpegturbo_turbojpeg_TJ_NUMCS
+#define org_libjpegturbo_turbojpeg_TJ_NUMCS 5L
+#undef org_libjpegturbo_turbojpeg_TJ_CS_RGB
+#define org_libjpegturbo_turbojpeg_TJ_CS_RGB 0L
+#undef org_libjpegturbo_turbojpeg_TJ_CS_YCbCr
+#define org_libjpegturbo_turbojpeg_TJ_CS_YCbCr 1L
+#undef org_libjpegturbo_turbojpeg_TJ_CS_GRAY
+#define org_libjpegturbo_turbojpeg_TJ_CS_GRAY 2L
+#undef org_libjpegturbo_turbojpeg_TJ_CS_CMYK
+#define org_libjpegturbo_turbojpeg_TJ_CS_CMYK 3L
+#undef org_libjpegturbo_turbojpeg_TJ_CS_YCCK
+#define org_libjpegturbo_turbojpeg_TJ_CS_YCCK 4L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP
#define org_libjpegturbo_turbojpeg_TJ_FLAG_BOTTOMUP 2L
#undef org_libjpegturbo_turbojpeg_TJ_FLAG_FORCEMMX
char *formatName(int subsamp, int cs, char *buf)
{
- if(cs==TJCS_YCbCr) return subNameLong[subsamp];
+ if(cs==TJCS_YCbCr) return (char *)subNameLong[subsamp];
else if(cs==TJCS_YCCK)
{
snprintf(buf, 80, "%s %s", csName[cs], subNameLong[subsamp]);
return buf;
}
- else return csName[cs];
+ else return (char *)csName[cs];
}
if(yuv==YUVENCODE) return;
if(yuv==YUVDECODE)
- printf("JPEG -> YUV %s ... ", subNameLong[subsamp]);
+ printf("JPEG -> YUV %s ", subNameLong[subsamp]);
else
printf("JPEG -> %s %s ", pixFormatStr[pf],
(flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down ");
{
tjhandle handle=0;
unsigned char *jpegBuf=NULL;
- int width=0, height=0, jpegSubsamp=-1;
+ int width=0, height=0, jpegSubsamp=-1, jpegColorspace=-1;
gethandle();
bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
- if(tjDecompressHeader2(handle, jpegBuf, (unsigned long)jpegSize,
- &width, &height, &jpegSubsamp)==-1)
+ if(tjDecompressHeader3(handle, jpegBuf, (unsigned long)jpegSize,
+ &width, &height, &jpegSubsamp, &jpegColorspace)==-1)
{
(*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
_throw(tjGetErrorStr());
bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
(*env)->SetIntField(env, obj, _fid, jpegSubsamp);
+ bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegColorspace", "I"));
+ (*env)->SetIntField(env, obj, _fid, jpegColorspace);
bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
(*env)->SetIntField(env, obj, _fid, width);
bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
};
+/**
+ * Red offset (in bytes) for a given pixel format. This specifies the number
+ * of bytes that the red component is offset from the start of the pixel. For
+ * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
+ * then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>.
+ */
+static const int tjRedOffset[TJ_NUMPF] = {0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1, -1};
+/**
+ * Green offset (in bytes) for a given pixel format. This specifies the number
+ * of bytes that the green component is offset from the start of the pixel.
+ * For instance, if a pixel of format TJ_BGRX is stored in
+ * <tt>char pixel[]</tt>, then the green component will be
+ * <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>.
+ */
+static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1};
+/**
+ * Blue offset (in bytes) for a given pixel format. This specifies the number
+ * of bytes that the Blue component is offset from the start of the pixel. For
+ * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
+ * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
+ */
+static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1};
+
+/**
+ * Pixel size (in bytes) for a given pixel format.
+ */
+static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4};
+
+
/**
* The number of JPEG colorspaces
*/
-#define TJ_NUMCS 12
+#define TJ_NUMCS 5
/**
* JPEG colorspaces
};
-/**
- * Red offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the red component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>.
- */
-static const int tjRedOffset[TJ_NUMPF] = {0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1, -1};
-/**
- * Green offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the green component is offset from the start of the pixel.
- * For instance, if a pixel of format TJ_BGRX is stored in
- * <tt>char pixel[]</tt>, then the green component will be
- * <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>.
- */
-static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1};
-/**
- * Blue offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the Blue component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
- */
-static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1};
-
-/**
- * Pixel size (in bytes) for a given pixel format.
- */
-static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4};
-
-
/**
* The uncompressed source/destination image is stored in bottom-up (Windows,
* OpenGL) order, not top-down (X11) order.