mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-12 00:04:17 +08:00
Java: Add official packed-pixel image I/O methods
This commit is contained in:
@@ -325,7 +325,7 @@ final class TJBench {
|
||||
(lossless ? "LOSSLS" : SUBNAME[subsamp]) + qualStr +
|
||||
"_" + sizeStr + "." + ext);
|
||||
|
||||
tjd.saveImage(precision, tempStr, dstBuf, scaledw, 0, scaledh, pf);
|
||||
tjd.saveImage(tempStr, dstBuf, 0, 0, scaledw, 0, scaledh, pf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1217,19 +1217,17 @@ final class TJBench {
|
||||
}
|
||||
|
||||
if (!decompOnly) {
|
||||
int[] width = new int[1], height = new int[1],
|
||||
pixelFormat = new int[1];
|
||||
|
||||
tjc = new TJCompressor();
|
||||
tjc.set(TJ.PARAM_STOPONWARNING, stopOnWarning ? 1 : 0);
|
||||
tjc.set(TJ.PARAM_BOTTOMUP, bottomUp ? 1 : 0);
|
||||
tjc.set(TJ.PARAM_PRECISION, precision);
|
||||
tjc.set(TJ.PARAM_MAXPIXELS, maxPixels);
|
||||
|
||||
pixelFormat[0] = pf;
|
||||
srcBuf = tjc.loadImage(precision, argv[0], width, 1, height,
|
||||
pixelFormat);
|
||||
w = width[0]; h = height[0]; pf = pixelFormat[0];
|
||||
tjc.loadSourceImage(argv[0], 1, pf);
|
||||
srcBuf = tjc.getSourceBuf();
|
||||
w = tjc.getWidth();
|
||||
h = tjc.getHeight();
|
||||
pf = tjc.getPixelFormat();
|
||||
int index = -1;
|
||||
if ((index = argv[0].lastIndexOf('.')) >= 0)
|
||||
argv[0] = argv[0].substring(0, index);
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.*;
|
||||
import java.awt.image.*;
|
||||
import javax.imageio.*;
|
||||
import java.nio.*;
|
||||
import java.nio.file.*;
|
||||
import org.libjpegturbo.turbojpeg.*;
|
||||
|
||||
@SuppressWarnings("checkstyle:JavadocType")
|
||||
@@ -105,6 +106,9 @@ final class TJUnitTest {
|
||||
|
||||
private static int exitStatus = 0;
|
||||
|
||||
private static String uniqueID =
|
||||
java.util.UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
static int biTypePF(int biType) {
|
||||
ByteOrder byteOrder = ByteOrder.nativeOrder();
|
||||
switch (biType) {
|
||||
@@ -1017,9 +1021,292 @@ final class TJUnitTest {
|
||||
if (tjc != null) tjc.close();
|
||||
}
|
||||
|
||||
static void rgbToCMYK(int r, int g, int b, int[] c, int[] m, int[] y,
|
||||
int[] k) {
|
||||
double ctmp = 1.0 - ((double)r / (double)maxSample);
|
||||
double mtmp = 1.0 - ((double)g / (double)maxSample);
|
||||
double ytmp = 1.0 - ((double)b / (double)maxSample);
|
||||
double ktmp = Math.min(Math.min(ctmp, mtmp), ytmp);
|
||||
|
||||
if (ktmp == 1.0)
|
||||
ctmp = mtmp = ytmp = 0.0;
|
||||
else {
|
||||
ctmp = (ctmp - ktmp) / (1.0 - ktmp);
|
||||
mtmp = (mtmp - ktmp) / (1.0 - ktmp);
|
||||
ytmp = (ytmp - ktmp) / (1.0 - ktmp);
|
||||
}
|
||||
c[0] = (int)((double)maxSample - ctmp * (double)maxSample + 0.5);
|
||||
m[0] = (int)((double)maxSample - mtmp * (double)maxSample + 0.5);
|
||||
y[0] = (int)((double)maxSample - ytmp * (double)maxSample + 0.5);
|
||||
k[0] = (int)((double)maxSample - ktmp * (double)maxSample + 0.5);
|
||||
}
|
||||
|
||||
static void initBitmap(Object buf, int width, int pitch, int height, int pf,
|
||||
boolean bottomUp) {
|
||||
int roffset = TJ.getRedOffset(pf);
|
||||
int goffset = TJ.getGreenOffset(pf);
|
||||
int boffset = TJ.getBlueOffset(pf);
|
||||
int ps = TJ.getPixelSize(pf);
|
||||
int i, j, ci;
|
||||
|
||||
for (j = 0; j < height; j++) {
|
||||
int row = bottomUp ? height - j - 1 : j;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
int r = (i * (maxSample + 1) / width) % (maxSample + 1);
|
||||
int g = (j * (maxSample + 1) / height) % (maxSample + 1);
|
||||
int b = (j * (maxSample + 1) / height +
|
||||
i * (maxSample + 1) / width) % (maxSample + 1);
|
||||
|
||||
for (ci = 0; ci < ps; ci++)
|
||||
setVal(buf, row * pitch + i * ps + ci, 0);
|
||||
if (pf == TJ.PF_GRAY)
|
||||
setVal(buf, row * pitch + i * ps, b);
|
||||
else if (pf == TJ.PF_CMYK) {
|
||||
int[] c = new int[1], m = new int[1], y = new int[1], k = new int[1];
|
||||
|
||||
rgbToCMYK(r, g, b, c, m, y, k);
|
||||
setVal(buf, row * pitch + i * ps + 0, c[0]);
|
||||
setVal(buf, row * pitch + i * ps + 1, m[0]);
|
||||
setVal(buf, row * pitch + i * ps + 2, y[0]);
|
||||
setVal(buf, row * pitch + i * ps + 3, k[0]);
|
||||
} else {
|
||||
setVal(buf, row * pitch + i * ps + roffset, r);
|
||||
setVal(buf, row * pitch + i * ps + goffset, g);
|
||||
setVal(buf, row * pitch + i * ps + boffset, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cmykToRGB(int c, int m, int y, int k, int[] r, int[] g,
|
||||
int[] b) {
|
||||
r[0] = (int)((double)c * (double)k / (double)maxSample + 0.5);
|
||||
g[0] = (int)((double)m * (double)k / (double)maxSample + 0.5);
|
||||
b[0] = (int)((double)y * (double)k / (double)maxSample + 0.5);
|
||||
}
|
||||
|
||||
static boolean cmpBitmap(Object buf, int width, int pitch, int height,
|
||||
int pf, boolean bottomUp, boolean gray2rgb) {
|
||||
int roffset = TJ.getRedOffset(pf);
|
||||
int goffset = TJ.getGreenOffset(pf);
|
||||
int boffset = TJ.getBlueOffset(pf);
|
||||
int aoffset = TJ.getAlphaOffset(pf);
|
||||
int ps = TJ.getPixelSize(pf);
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < height; j++) {
|
||||
int row = bottomUp ? height - j - 1 : j;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
int r = (i * (maxSample + 1) / width) % (maxSample + 1);
|
||||
int g = (j * (maxSample + 1) / height) % (maxSample + 1);
|
||||
int b = (j * (maxSample + 1) / height +
|
||||
i * (maxSample + 1) / width) % (maxSample + 1);
|
||||
|
||||
if (pf == TJ.PF_GRAY) {
|
||||
if (getVal(buf, row * pitch + i * ps) != b)
|
||||
return false;
|
||||
} else if (pf == TJ.PF_CMYK) {
|
||||
int[] rf = new int[1], gf = new int[1], bf = new int[1];
|
||||
|
||||
cmykToRGB(getVal(buf, row * pitch + i * ps + 0),
|
||||
getVal(buf, row * pitch + i * ps + 1),
|
||||
getVal(buf, row * pitch + i * ps + 2),
|
||||
getVal(buf, row * pitch + i * ps + 3), rf, gf, bf);
|
||||
if (gray2rgb) {
|
||||
if (rf[0] != b || gf[0] != b || bf[0] != b)
|
||||
return false;
|
||||
} else if (rf[0] != r || gf[0] != g || bf[0] != b)
|
||||
return false;
|
||||
} else {
|
||||
if (gray2rgb) {
|
||||
if (getVal(buf, row * pitch + i * ps + roffset) != b ||
|
||||
getVal(buf, row * pitch + i * ps + goffset) != b ||
|
||||
getVal(buf, row * pitch + i * ps + boffset) != b)
|
||||
return false;
|
||||
} else if (getVal(buf, row * pitch + i * ps + roffset) != r ||
|
||||
getVal(buf, row * pitch + i * ps + goffset) != g ||
|
||||
getVal(buf, row * pitch + i * ps + boffset) != b)
|
||||
return false;
|
||||
if (aoffset >= 0 &&
|
||||
getVal(buf, row * pitch + i * ps + aoffset) != maxSample)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static String getMD5Sum(String filename) throws Exception {
|
||||
byte[] bytes = Files.readAllBytes(Paths.get(filename));
|
||||
byte[] md5sum =
|
||||
java.security.MessageDigest.getInstance("MD5").digest(bytes);
|
||||
return new java.math.BigInteger(1, md5sum).toString(16);
|
||||
}
|
||||
|
||||
static void doBmpTest(String ext, int width, int align, int height, int pf,
|
||||
boolean bottomUp) throws Exception {
|
||||
TJCompressor tjc = null;
|
||||
TJDecompressor tjd = null;
|
||||
String filename, md5sum;
|
||||
int ps = TJ.getPixelSize(pf), pitch = pad(width * ps, align),
|
||||
loadWidth = 0, loadPitch = 0, loadHeight = 0, pixelFormat = pf;
|
||||
Object buf = null;
|
||||
String md5ref;
|
||||
String[] colorPPMRefs = new String[] {
|
||||
"", "", "bad09d9ef38eda566848fb7c0b7fd0a",
|
||||
"7ef2c87261a8bd6838303b541563cf27", "28a37cf9636ff6bb9ed6b206bdac60db",
|
||||
"723307791d42e0b5f9e91625c7636086", "d729c4bcd3addc14abc16b656c6bbc98",
|
||||
"5d7636eedae3cf579b6de13078227548", "c0c9f772b464d1896326883a5c79c545",
|
||||
"fcf6490e0445569427f1d95baf5f8fcb", "5cbc3b0ccba23f5781d950a72e0ccc83",
|
||||
"d4e26d6d16d7bfee380f6feb10f7e53", "2ff5299287017502832c99718450c90a",
|
||||
"44ae6cd70c798ea583ab0c8c03621092", "697b2fe03892bc9a75396ad3e73d9203",
|
||||
"599732f973eb7c0849a888e783bbe27e", "623f54661b928d170bd2324bc3620565"
|
||||
};
|
||||
String[] grayPPMRefs = new String[] {
|
||||
"", "", "7565be35a2ce909cae016fa282af8efa",
|
||||
"e86b9ea57f7d53f6b5497653740992b5", "8924d4d81fe0220c684719294f93407a",
|
||||
"e2e69ba70efcfae317528c91651c7ae2", "e6154aafc1eb9e4333d68ce7ad9df051",
|
||||
"3d7fe831d6fbe55d3fa12f52059c15d3", "112c682e82ce5de1cca089e20d60000b",
|
||||
"5a7ce86c649dda86d6fed185ab78a67", "b723c0bc087592816523fbc906b7c3a",
|
||||
"5da422b1ddfd44c7659094d42ba5580c", "d1895c7e6f2b2c9af6e821a655c239c",
|
||||
"fc2803bca103ff75785ea0dca992aa", "d8c91fac522c16b029e514d331a22bc4",
|
||||
"e50cff0b3562ed7e64dbfc093440e333", "64f3320b226ea37fb58080713b4df1b2"
|
||||
};
|
||||
|
||||
try {
|
||||
tjc = new TJCompressor();
|
||||
tjc.set(TJ.PARAM_BOTTOMUP, bottomUp ? 1 : 0);
|
||||
tjc.set(TJ.PARAM_PRECISION, precision);
|
||||
tjd = new TJDecompressor();
|
||||
tjd.set(TJ.PARAM_BOTTOMUP, bottomUp ? 1 : 0);
|
||||
tjd.set(TJ.PARAM_PRECISION, precision);
|
||||
|
||||
if (precision == 8 && ext.equalsIgnoreCase("bmp"))
|
||||
md5ref = (pf == TJ.PF_GRAY ? "51976530acf75f02beddf5d21149101d" :
|
||||
"6d659071b9bfcdee2def22cb58ddadca");
|
||||
else
|
||||
md5ref = (pf == TJ.PF_GRAY ? grayPPMRefs[precision] :
|
||||
colorPPMRefs[precision]);
|
||||
|
||||
if (precision <= 8)
|
||||
buf = new byte[pitch * height];
|
||||
else
|
||||
buf = new short[pitch * height];
|
||||
initBitmap(buf, width, pitch, height, pf, bottomUp);
|
||||
|
||||
filename = String.format("test_bmp%d_%s_%d_%s_%s.%s", precision,
|
||||
PIXFORMATSTR[pf], align, bottomUp ? "bu" : "td",
|
||||
uniqueID, ext);
|
||||
tjd.saveImage(filename, buf, 0, 0, width, pitch, height, pf);
|
||||
md5sum = getMD5Sum(filename);
|
||||
if (md5sum == null)
|
||||
throw new Exception("Could not determine MD5 sum of " + filename);
|
||||
if (!md5sum.equalsIgnoreCase(md5ref))
|
||||
throw new Exception(filename + " has an MD5 sum of " + md5sum +
|
||||
". Should be " + md5ref);
|
||||
|
||||
tjc.loadSourceImage(filename, align, pf);
|
||||
loadWidth = tjc.getWidth();
|
||||
loadPitch = tjc.getPitch();
|
||||
loadHeight = tjc.getHeight();
|
||||
pf = tjc.getPixelFormat();
|
||||
buf = tjc.getSourceBuf();
|
||||
if (width != loadWidth || pitch != loadPitch || height != loadHeight)
|
||||
throw new Exception("Image dimensions of " + filename + " are bogus");
|
||||
if (!cmpBitmap(buf, width, pitch, height, pf, bottomUp, false))
|
||||
throw new Exception("Pixel data in " + filename + " is bogus");
|
||||
if (pf == TJ.PF_GRAY) {
|
||||
pf = TJ.PF_XBGR;
|
||||
tjc.loadSourceImage(filename, align, pf);
|
||||
loadWidth = tjc.getWidth();
|
||||
loadPitch = tjc.getPitch();
|
||||
loadHeight = tjc.getHeight();
|
||||
pf = tjc.getPixelFormat();
|
||||
buf = tjc.getSourceBuf();
|
||||
pitch = pad(width * TJ.getPixelSize(pf), align);
|
||||
if (width != loadWidth || pitch != loadPitch || height != loadHeight)
|
||||
throw new Exception("Image dimensions of " + filename +
|
||||
" are bogus");
|
||||
if (!cmpBitmap(buf, width, pitch, height, pf, bottomUp, true))
|
||||
throw new Exception("Converting " + filename + " to RGB failed");
|
||||
|
||||
pf = TJ.PF_CMYK;
|
||||
tjc.loadSourceImage(filename, align, pf);
|
||||
loadWidth = tjc.getWidth();
|
||||
loadPitch = tjc.getPitch();
|
||||
loadHeight = tjc.getHeight();
|
||||
pf = tjc.getPixelFormat();
|
||||
buf = tjc.getSourceBuf();
|
||||
pitch = pad(width * TJ.getPixelSize(pf), align);
|
||||
if (width != loadWidth || pitch != loadPitch || height != loadHeight)
|
||||
throw new Exception("Image dimensions of " + filename +
|
||||
" are bogus");
|
||||
if (!cmpBitmap(buf, width, pitch, height, pf, bottomUp, true))
|
||||
throw new Exception("Converting " + filename + " to CMYK failed");
|
||||
}
|
||||
/* Verify that TJCompressor.loadSourceImage() returns the proper
|
||||
"preferred" pixel format for the file type. */
|
||||
pf = pixelFormat;
|
||||
pixelFormat = TJ.PF_UNKNOWN;
|
||||
tjc.loadSourceImage(filename, align, pixelFormat);
|
||||
pixelFormat = tjc.getPixelFormat();
|
||||
if ((pf == TJ.PF_GRAY && pixelFormat != TJ.PF_GRAY) ||
|
||||
(pf != TJ.PF_GRAY && ext.equalsIgnoreCase("bmp") &&
|
||||
pixelFormat != TJ.PF_BGR) ||
|
||||
(pf != TJ.PF_GRAY && ext.equalsIgnoreCase("ppm") &&
|
||||
pixelFormat != TJ.PF_RGB))
|
||||
throw new Exception("TJCompressor.loadImage() returned unexpected " +
|
||||
"pixel format: " + PIXFORMATSTR[pixelFormat]);
|
||||
File file = new File(filename);
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
if (tjc != null) tjc.close();
|
||||
if (tjd != null) tjd.close();
|
||||
throw e;
|
||||
}
|
||||
if (tjc != null) tjc.close();
|
||||
if (tjd != null) tjd.close();
|
||||
}
|
||||
|
||||
static void bmpTest() throws Exception {
|
||||
int align, width = 35, height = 39, format;
|
||||
|
||||
for (align = 1; align <= 8; align *= 2) {
|
||||
for (format = 0; format < TJ.NUMPF; format++) {
|
||||
if (precision == 8) {
|
||||
System.out.format("%s Top-Down BMP (row alignment = %d samples) ... ",
|
||||
PIXFORMATSTR[format], align);
|
||||
doBmpTest("bmp", width, align, height, format, false);
|
||||
System.out.println("OK.");
|
||||
}
|
||||
|
||||
System.out.format("%s Top-Down PPM (row alignment = %d samples) ... ",
|
||||
PIXFORMATSTR[format], align);
|
||||
doBmpTest("ppm", width, align, height, format, true);
|
||||
System.out.println("OK.");
|
||||
|
||||
if (precision == 8) {
|
||||
System.out.format("%s Bottom-Up BMP (row alignment = %d samples) ... ",
|
||||
PIXFORMATSTR[format], align);
|
||||
doBmpTest("bmp", width, align, height, format, false);
|
||||
System.out.println("OK.");
|
||||
}
|
||||
|
||||
System.out.format("%s Bottom-Up PPM (row alignment = %d samples) ... ",
|
||||
PIXFORMATSTR[format], align);
|
||||
doBmpTest("ppm", width, align, height, format, true);
|
||||
System.out.println("OK.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
try {
|
||||
String testName = "javatest";
|
||||
boolean bmp = false;
|
||||
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
if (argv[i].equalsIgnoreCase("-yuv"))
|
||||
doYUV = true;
|
||||
@@ -1030,8 +1317,10 @@ final class TJUnitTest {
|
||||
else if (argv[i].equalsIgnoreCase("-bi")) {
|
||||
bi = true;
|
||||
testName = "javabitest";
|
||||
} else if (argv[i].equalsIgnoreCase("-precision") &&
|
||||
i < argv.length - 1) {
|
||||
} else if (argv[i].equalsIgnoreCase("-bmp"))
|
||||
bmp = true;
|
||||
else if (argv[i].equalsIgnoreCase("-precision") &&
|
||||
i < argv.length - 1) {
|
||||
int tempi = -1;
|
||||
|
||||
try {
|
||||
@@ -1059,6 +1348,10 @@ final class TJUnitTest {
|
||||
redToY = (19595 * maxSample) >> 16;
|
||||
yellowToY = (58065 * maxSample) >> 16;
|
||||
|
||||
if (bmp) {
|
||||
bmpTest();
|
||||
System.exit(exitStatus);
|
||||
}
|
||||
if (doYUV)
|
||||
FORMATS_4SAMPLE[4] = -1;
|
||||
overflowTest();
|
||||
|
||||
@@ -431,69 +431,76 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<td class="colLast"><code>2</code></td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.PF_UNKNOWN">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#PF_UNKNOWN">PF_UNKNOWN</a></code></th>
|
||||
<td class="colLast"><code>-1</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.PF_XBGR">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#PF_XBGR">PF_XBGR</a></code></th>
|
||||
<td class="colLast"><code>4</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.PF_XRGB">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#PF_XRGB">PF_XRGB</a></code></th>
|
||||
<td class="colLast"><code>5</code></td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_411">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_411">SAMP_411</a></code></th>
|
||||
<td class="colLast"><code>5</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_420">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_420">SAMP_420</a></code></th>
|
||||
<td class="colLast"><code>2</code></td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_422">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_422">SAMP_422</a></code></th>
|
||||
<td class="colLast"><code>1</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_440">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_440">SAMP_440</a></code></th>
|
||||
<td class="colLast"><code>4</code></td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_441">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_441">SAMP_441</a></code></th>
|
||||
<td class="colLast"><code>6</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_444">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_444">SAMP_444</a></code></th>
|
||||
<td class="colLast"><code>0</code></td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_GRAY">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
<th class="colSecond" scope="row"><code><a href="org/libjpegturbo/turbojpeg/TJ.html#SAMP_GRAY">SAMP_GRAY</a></code></th>
|
||||
<td class="colLast"><code>3</code></td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><a id="org.libjpegturbo.turbojpeg.TJ.SAMP_UNKNOWN">
|
||||
<!-- -->
|
||||
</a><code>public static final int</code></td>
|
||||
|
||||
@@ -91,7 +91,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
</nav>
|
||||
</header>
|
||||
<main role="main">
|
||||
<div class="contentContainer"><a href="#I:B">B</a> <a href="#I:C">C</a> <a href="#I:D">D</a> <a href="#I:E">E</a> <a href="#I:F">F</a> <a href="#I:G">G</a> <a href="#I:I">I</a> <a href="#I:N">N</a> <a href="#I:O">O</a> <a href="#I:P">P</a> <a href="#I:S">S</a> <a href="#I:T">T</a> <a href="#I:U">U</a> <a href="#I:Y">Y</a> <br><a href="allclasses-index.html">All Classes</a> <a href="allpackages-index.html">All Packages</a><a id="I:B">
|
||||
<div class="contentContainer"><a href="#I:B">B</a> <a href="#I:C">C</a> <a href="#I:D">D</a> <a href="#I:E">E</a> <a href="#I:F">F</a> <a href="#I:G">G</a> <a href="#I:I">I</a> <a href="#I:L">L</a> <a href="#I:N">N</a> <a href="#I:O">O</a> <a href="#I:P">P</a> <a href="#I:S">S</a> <a href="#I:T">T</a> <a href="#I:U">U</a> <a href="#I:Y">Y</a> <br><a href="allclasses-index.html">All Classes</a> <a href="allpackages-index.html">All Packages</a><a id="I:B">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h2 class="title">B</h2>
|
||||
@@ -345,6 +345,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<div class="block">For the given pixel format, returns the number of samples that the green
|
||||
component is offset from the start of the pixel.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#getHeight()">getHeight()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the height of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJDecompressor.html#getHeight()">getHeight()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the height of the source image (JPEG or YUV) associated with this
|
||||
@@ -387,6 +392,16 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<div class="block">Returns the row alignment (in bytes) of the YUV buffer (if this image is
|
||||
stored in a unified buffer rather than separate image planes.)</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#getPitch()">getPitch()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the pitch (samples per row) of the packed-pixel source image
|
||||
associated with this compressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#getPixelFormat()">getPixelFormat()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the pixel format of the packed-pixel source image associated with
|
||||
this compressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJ.html#getPixelSize(int)">getPixelSize(int)</a></span> - Static method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the pixel size (in samples) for the given pixel format.</div>
|
||||
@@ -414,6 +429,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<div class="block">Returns the size (in bytes) of the YUV buffer (if this image is stored in
|
||||
a unified buffer rather than separate image planes.)</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#getSourceBuf()">getSourceBuf()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the buffer containing the packed-pixel image associated with this
|
||||
compressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/YUVImage.html#getStrides()">getStrides()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the number of bytes per row of each plane in the YUV image.</div>
|
||||
@@ -427,6 +447,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<div class="block">Returns an array containing the sizes of the transformed JPEG images
|
||||
(in bytes) generated by the most recent transform operation.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#getWidth()">getWidth()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the width of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJDecompressor.html#getWidth()">getWidth()</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Returns the width of the source image (JPEG or YUV) associated with this
|
||||
@@ -448,6 +473,18 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
1/1.</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<a id="I:L">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h2 class="title">L</h2>
|
||||
<dl>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#loadSourceImage(java.lang.String,int,int)">loadSourceImage(String, int, int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Load a packed-pixel RGB or grayscale source image with 2 to 16 bits of
|
||||
data precision per sample from disk into memory and associate it with this
|
||||
compressor instance.</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<a id="I:N">
|
||||
<!-- -->
|
||||
</a>
|
||||
@@ -712,6 +749,10 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<dd>
|
||||
<div class="block">RGBX pixel format</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJ.html#PF_UNKNOWN">PF_UNKNOWN</a></span> - Static variable in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
||||
<dd>
|
||||
<div class="block">Unknown pixel format</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJ.html#PF_XBGR">PF_XBGR</a></span> - Static variable in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
||||
<dd>
|
||||
<div class="block">XBGR pixel format</div>
|
||||
@@ -771,6 +812,11 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
<dd>
|
||||
<div class="block">Unknown subsampling</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)">saveImage(String, Object, int, int, int, int, int, int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Save a packed-pixel image with 2 to 16 bits of data precision per sample
|
||||
from memory to disk.</div>
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="org/libjpegturbo/turbojpeg/TJCompressor.html#set(int,int)">set(int, int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Set the value of a compression parameter.</div>
|
||||
@@ -1008,7 +1054,7 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
||||
and allocate memory for the buffer.</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<a href="#I:B">B</a> <a href="#I:C">C</a> <a href="#I:D">D</a> <a href="#I:E">E</a> <a href="#I:F">F</a> <a href="#I:G">G</a> <a href="#I:I">I</a> <a href="#I:N">N</a> <a href="#I:O">O</a> <a href="#I:P">P</a> <a href="#I:S">S</a> <a href="#I:T">T</a> <a href="#I:U">U</a> <a href="#I:Y">Y</a> <br><a href="allclasses-index.html">All Classes</a> <a href="allpackages-index.html">All Packages</a></div>
|
||||
<a href="#I:B">B</a> <a href="#I:C">C</a> <a href="#I:D">D</a> <a href="#I:E">E</a> <a href="#I:F">F</a> <a href="#I:G">G</a> <a href="#I:I">I</a> <a href="#I:L">L</a> <a href="#I:N">N</a> <a href="#I:O">O</a> <a href="#I:P">P</a> <a href="#I:S">S</a> <a href="#I:T">T</a> <a href="#I:U">U</a> <a href="#I:Y">Y</a> <br><a href="allclasses-index.html">All Classes</a> <a href="allpackages-index.html">All Packages</a></div>
|
||||
</main>
|
||||
<footer role="contentinfo">
|
||||
<nav role="navigation">
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -478,82 +478,89 @@ extends java.lang.Object</pre>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#PF_UNKNOWN">PF_UNKNOWN</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Unknown pixel format</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#PF_XBGR">PF_XBGR</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">XBGR pixel format</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#PF_XRGB">PF_XRGB</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">XRGB pixel format</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_411">SAMP_411</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:1:1 chrominance subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_420">SAMP_420</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:2:0 chrominance subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_422">SAMP_422</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:2:2 chrominance subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_440">SAMP_440</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:4:0 chrominance subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_441">SAMP_441</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:4:1 chrominance subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_444">SAMP_444</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">4:4:4 chrominance subsampling (no chrominance subsampling)</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_GRAY">SAMP_GRAY</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Grayscale</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#SAMP_UNKNOWN">SAMP_UNKNOWN</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Unknown subsampling</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static java.awt.Rectangle</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#UNCROPPED">UNCROPPED</a></span></code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">A <code>java.awt.Rectangle</code> instance that specifies no cropping</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static <a href="TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a></code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#UNSCALED">UNSCALED</a></span></code></th>
|
||||
<td class="colLast">
|
||||
@@ -1131,6 +1138,23 @@ extends java.lang.Object</pre>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="PF_UNKNOWN">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>PF_UNKNOWN</h4>
|
||||
<pre>public static final int PF_UNKNOWN</pre>
|
||||
<div class="block">Unknown pixel format
|
||||
|
||||
<p>Currently this is only used by
|
||||
<a href="TJCompressor.html#loadSourceImage(java.lang.String,int,int)"><code>TJCompressor.loadSourceImage()</code></a>.</div>
|
||||
<dl>
|
||||
<dt><span class="seeLabel">See Also:</span></dt>
|
||||
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PF_UNKNOWN">Constant Field Values</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="NUMCS">
|
||||
<!-- -->
|
||||
</a>
|
||||
@@ -1390,7 +1414,11 @@ extends java.lang.Object</pre>
|
||||
<div class="block">Data precision (bits per sample)
|
||||
|
||||
<p>The JPEG image uses (decompression) or will use (lossless compression)
|
||||
the specified number of bits per sample.
|
||||
the specified number of bits per sample. This parameter also specifies
|
||||
the target data precision when loading a PBMPLUS file with
|
||||
<a href="TJCompressor.html#loadSourceImage(java.lang.String,int,int)"><code>TJCompressor.loadSourceImage()</code></a> and
|
||||
the source data precision when saving a PBMPLUS file with
|
||||
<a href="TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)"><code>TJDecompressor.saveImage()</code></a>.
|
||||
|
||||
<p>The data precision is the number of bits in the maximum sample value,
|
||||
which may not be the same as the width of the data type used to store the
|
||||
@@ -1399,7 +1427,7 @@ extends java.lang.Object</pre>
|
||||
<p><b>Value</b>
|
||||
<ul>
|
||||
<li> <code>8</code> or <code>12</code> for lossy JPEG images;
|
||||
<code>2</code> to <code>16</code> for lossless JPEG images
|
||||
<code>2</code> to <code>16</code> for lossless JPEG and PBMPLUS images
|
||||
</ul>
|
||||
|
||||
<p>12-bit JPEG data precision implies <a href="#PARAM_OPTIMIZE"><code>PARAM_OPTIMIZE</code></a> unless
|
||||
@@ -1819,7 +1847,12 @@ extends java.lang.Object</pre>
|
||||
</ul>
|
||||
|
||||
<p>This value is stored in or read from the JPEG header. It does not
|
||||
affect the contents of the JPEG image.</div>
|
||||
affect the contents of the JPEG image. Note that this parameter is set by
|
||||
<a href="TJCompressor.html#loadSourceImage(java.lang.String,int,int)"><code>TJCompressor.loadSourceImage()</code></a> when
|
||||
loading a Windows BMP file that contains pixel density information, and
|
||||
the value of this parameter is stored to a Windows BMP file by
|
||||
<a href="TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)"><code>TJDecompressor.saveImage()</code></a> if the value
|
||||
of <a href="#PARAM_DENSITYUNITS"><code>PARAM_DENSITYUNITS</code></a> is <code>2</code>.</div>
|
||||
<dl>
|
||||
<dt><span class="seeLabel">See Also:</span></dt>
|
||||
<dd><a href="#PARAM_DENSITYUNITS"><code>PARAM_DENSITYUNITS</code></a>,
|
||||
@@ -1844,7 +1877,12 @@ extends java.lang.Object</pre>
|
||||
</ul>
|
||||
|
||||
<p>This value is stored in or read from the JPEG header. It does not
|
||||
affect the contents of the JPEG image.</div>
|
||||
affect the contents of the JPEG image. Note that this parameter is set by
|
||||
<a href="TJCompressor.html#loadSourceImage(java.lang.String,int,int)"><code>TJCompressor.loadSourceImage()</code></a> when
|
||||
loading a Windows BMP file that contains pixel density information, and
|
||||
the value of this parameter is stored to a Windows BMP file by
|
||||
<a href="TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)"><code>TJDecompressor.saveImage()</code></a> if the value
|
||||
of <a href="#PARAM_DENSITYUNITS"><code>PARAM_DENSITYUNITS</code></a> is <code>2</code>.</div>
|
||||
<dl>
|
||||
<dt><span class="seeLabel">See Also:</span></dt>
|
||||
<dd><a href="#PARAM_DENSITYUNITS"><code>PARAM_DENSITYUNITS</code></a>,
|
||||
@@ -1874,7 +1912,12 @@ extends java.lang.Object</pre>
|
||||
</ul>
|
||||
|
||||
<p>This value is stored in or read from the JPEG header. It does not
|
||||
affect the contents of the JPEG image.</div>
|
||||
affect the contents of the JPEG image. Note that this parameter is set by
|
||||
<a href="TJCompressor.html#loadSourceImage(java.lang.String,int,int)"><code>TJCompressor.loadSourceImage()</code></a> when
|
||||
loading a Windows BMP file that contains pixel density information, and
|
||||
the value of this parameter is stored to a Windows BMP file by
|
||||
<a href="TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)"><code>TJDecompressor.saveImage()</code></a> if the value
|
||||
is <code>2</code>.</div>
|
||||
<dl>
|
||||
<dt><span class="seeLabel">See Also:</span></dt>
|
||||
<dd><a href="#PARAM_XDENSITY"><code>PARAM_XDENSITY</code></a>,
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10};
|
||||
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10};
|
||||
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
||||
var altColor = "altColor";
|
||||
var rowColor = "rowColor";
|
||||
@@ -280,6 +280,57 @@ implements java.io.Closeable</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i9" class="rowColor">
|
||||
<td class="colFirst"><code>int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getHeight()">getHeight</a></span>()</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Returns the height of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i10" class="altColor">
|
||||
<td class="colFirst"><code>int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getPitch()">getPitch</a></span>()</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Returns the pitch (samples per row) of the packed-pixel source image
|
||||
associated with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i11" class="rowColor">
|
||||
<td class="colFirst"><code>int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getPixelFormat()">getPixelFormat</a></span>()</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Returns the pixel format of the packed-pixel source image associated with
|
||||
this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i12" class="altColor">
|
||||
<td class="colFirst"><code>java.lang.Object</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSourceBuf()">getSourceBuf</a></span>()</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Returns the buffer containing the packed-pixel image associated with this
|
||||
compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i13" class="rowColor">
|
||||
<td class="colFirst"><code>int</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWidth()">getWidth</a></span>()</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Returns the width of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i14" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#loadSourceImage(java.lang.String,int,int)">loadSourceImage</a></span>​(java.lang.String fileName,
|
||||
int align,
|
||||
int pixelFormat)</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Load a packed-pixel RGB or grayscale source image with 2 to 16 bits of
|
||||
data precision per sample from disk into memory and associate it with this
|
||||
compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i15" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#set(int,int)">set</a></span>​(int param,
|
||||
int value)</code></th>
|
||||
@@ -287,7 +338,7 @@ implements java.io.Closeable</pre>
|
||||
<div class="block">Set the value of a compression parameter.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i10" class="altColor">
|
||||
<tr id="i16" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage(byte%5B%5D,int,int,int,int,int,int)">setSourceImage</a></span>​(byte[] srcImage,
|
||||
int x,
|
||||
@@ -301,7 +352,7 @@ implements java.io.Closeable</pre>
|
||||
bits of data precision per sample with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i11" class="rowColor">
|
||||
<tr id="i17" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage(java.awt.image.BufferedImage,int,int,int,int)">setSourceImage</a></span>​(java.awt.image.BufferedImage srcImage,
|
||||
int x,
|
||||
@@ -313,7 +364,7 @@ implements java.io.Closeable</pre>
|
||||
with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i12" class="altColor">
|
||||
<tr id="i18" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage(org.libjpegturbo.turbojpeg.YUVImage)">setSourceImage</a></span>​(<a href="YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a> srcImage)</code></th>
|
||||
<td class="colLast">
|
||||
@@ -321,7 +372,7 @@ implements java.io.Closeable</pre>
|
||||
instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i13" class="rowColor">
|
||||
<tr id="i19" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage12(short%5B%5D,int,int,int,int,int,int)">setSourceImage12</a></span>​(short[] srcImage,
|
||||
int x,
|
||||
@@ -335,7 +386,7 @@ implements java.io.Closeable</pre>
|
||||
bits of data precision per sample with this compressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i14" class="altColor">
|
||||
<tr id="i20" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage16(short%5B%5D,int,int,int,int,int,int)">setSourceImage16</a></span>​(short[] srcImage,
|
||||
int x,
|
||||
@@ -662,6 +713,150 @@ implements java.io.Closeable</pre>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="loadSourceImage(java.lang.String,int,int)">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>loadSourceImage</h4>
|
||||
<pre class="methodSignature">public void loadSourceImage​(java.lang.String fileName,
|
||||
int align,
|
||||
int pixelFormat)
|
||||
throws <a href="TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></pre>
|
||||
<div class="block">Load a packed-pixel RGB or grayscale source image with 2 to 16 bits of
|
||||
data precision per sample from disk into memory and associate it with this
|
||||
compressor instance. Note that packed-pixel source images with 2 to 7, 9
|
||||
to 11, or 13 to 16 bits of data precision per sample can only be
|
||||
compressed into lossless JPEG images.
|
||||
|
||||
<p><a href="#getWidth()"><code>getWidth()</code></a>, <a href="#getPitch()"><code>getPitch()</code></a>, <a href="#getHeight()"><code>getHeight()</code></a>,
|
||||
<a href="#getPixelFormat()"><code>getPixelFormat()</code></a>, and <a href="#getSourceBuf()"><code>getSourceBuf()</code></a> can be used to
|
||||
obtain the source image's dimensions, pixel format, and buffer after it is
|
||||
loaded.</div>
|
||||
<dl>
|
||||
<dt><span class="paramLabel">Parameters:</span></dt>
|
||||
<dd><code>fileName</code> - name of a file containing a packed-pixel image in Windows
|
||||
BMP or PBMPLUS (PPM/PGM) format. Windows BMP files require
|
||||
8-bit-per-sample data precision. When loading a PBMPLUS file, the target
|
||||
data precision (from 2 to 16 bits per sample) can be specified using
|
||||
<a href="TJ.html#PARAM_PRECISION"><code>TJ.PARAM_PRECISION</code></a> and defaults to 8 if <a href="TJ.html#PARAM_PRECISION"><code>TJ.PARAM_PRECISION</code></a>
|
||||
is unset. If the data precision of the PBMPLUS file does not match the
|
||||
target data precision, then upconverting or downconverting will be
|
||||
performed.</dd>
|
||||
<dd><code>align</code> - row alignment (in samples) of the packed-pixel buffer into
|
||||
which the source image will be loaded (must be a power of 2.) Setting
|
||||
this parameter to n will cause all rows in the buffer to be padded to the
|
||||
nearest multiple of n samples (1 = unpadded.)</dd>
|
||||
<dd><code>pixelFormat</code> - pixel format of the packed-pixel buffer into which the
|
||||
source image will be loaded. The behavior of this method varies depending
|
||||
on the value of <code>pixelFormat</code>:
|
||||
<ul>
|
||||
<li> <a href="TJ.html#PF_UNKNOWN"><code>TJ.PF_UNKNOWN</code></a> : The packed-pixel buffer created by this
|
||||
method will use the most optimal pixel format for the file type. Use
|
||||
<a href="#getPixelFormat()"><code>getPixelFormat()</code></a> to obtain the ID of that pixel format.
|
||||
<li> <a href="TJ.html#PF_GRAY"><code>TJ.PF_GRAY</code></a> : Only PGM files and 8-bit-per-pixel BMP files
|
||||
with a grayscale colormap can be loaded.
|
||||
<li> <a href="TJ.html#PF_CMYK"><code>TJ.PF_CMYK</code></a> : The RGB or grayscale pixels stored in the file
|
||||
will be converted using a quick & dirty algorithm that is suitable
|
||||
only for testing purposes. (Proper conversion between CMYK and other
|
||||
formats requires a color management system.)
|
||||
<li> Other <a href="TJ.html#PF_RGB"><code>pixel formats</code></a> : The packed-pixel buffer
|
||||
will use the specified pixel format, and pixel format conversion will be
|
||||
performed if necessary.
|
||||
</ul></dd>
|
||||
<dt><span class="throwsLabel">Throws:</span></dt>
|
||||
<dd><code><a href="TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></code></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="getWidth()">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getWidth</h4>
|
||||
<pre class="methodSignature">public int getWidth()</pre>
|
||||
<div class="block">Returns the width of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
<dl>
|
||||
<dt><span class="returnLabel">Returns:</span></dt>
|
||||
<dd>the width of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="getPitch()">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getPitch</h4>
|
||||
<pre class="methodSignature">public int getPitch()</pre>
|
||||
<div class="block">Returns the pitch (samples per row) of the packed-pixel source image
|
||||
associated with this compressor instance. If the source image is a
|
||||
<code>BufferedImage</code> instance with integer pixels, then the stride
|
||||
(pixels per row) is returned instead.</div>
|
||||
<dl>
|
||||
<dt><span class="returnLabel">Returns:</span></dt>
|
||||
<dd>the pitch (samples per row) of the packed-pixel source image
|
||||
associated with this compressor instance.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="getHeight()">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getHeight</h4>
|
||||
<pre class="methodSignature">public int getHeight()</pre>
|
||||
<div class="block">Returns the height of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</div>
|
||||
<dl>
|
||||
<dt><span class="returnLabel">Returns:</span></dt>
|
||||
<dd>the height of the source image (packed-pixel or YUV) associated
|
||||
with this compressor instance.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="getPixelFormat()">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getPixelFormat</h4>
|
||||
<pre class="methodSignature">public int getPixelFormat()</pre>
|
||||
<div class="block">Returns the pixel format of the packed-pixel source image associated with
|
||||
this compressor instance. The pixel format is one of
|
||||
<a href="TJ.html#PF_RGB"><code>TJ.PF_*</code></a>.</div>
|
||||
<dl>
|
||||
<dt><span class="returnLabel">Returns:</span></dt>
|
||||
<dd>the pixel format of the packed-pixel source image associated with
|
||||
this compressor instance.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="getSourceBuf()">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getSourceBuf</h4>
|
||||
<pre class="methodSignature">public java.lang.Object getSourceBuf()</pre>
|
||||
<div class="block">Returns the buffer containing the packed-pixel image associated with this
|
||||
compressor instance. The buffer is a <code>byte</code> array if the
|
||||
source image has 2 to 8 bits of data precision per sample, a
|
||||
<code>short</code> array if the source image has 9 to 16 bits of data
|
||||
precision per sample, and either a <code>byte</code> or an
|
||||
<code>int</code> array (depending on the image type) if the source image
|
||||
is a <code>BufferedImage</code> instance.</div>
|
||||
<dl>
|
||||
<dt><span class="returnLabel">Returns:</span></dt>
|
||||
<dd>the buffer containing the packed-pixel image associated with this
|
||||
compressor instance.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="set(int,int)">
|
||||
<!-- -->
|
||||
</a>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10};
|
||||
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":10};
|
||||
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
||||
var altColor = "altColor";
|
||||
var rowColor = "rowColor";
|
||||
@@ -398,13 +398,28 @@ implements java.io.Closeable</pre>
|
||||
</tr>
|
||||
<tr id="i19" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)">saveImage</a></span>​(java.lang.String fileName,
|
||||
java.lang.Object image,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int pitch,
|
||||
int height,
|
||||
int pixelFormat)</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Save a packed-pixel image with 2 to 16 bits of data precision per sample
|
||||
from memory to disk.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i20" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#set(int,int)">set</a></span>​(int param,
|
||||
int value)</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Set the value of a decompression parameter.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i20" class="altColor">
|
||||
<tr id="i21" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setCroppingRegion(java.awt.Rectangle)">setCroppingRegion</a></span>​(java.awt.Rectangle croppingRegion)</code></th>
|
||||
<td class="colLast">
|
||||
@@ -412,14 +427,14 @@ implements java.io.Closeable</pre>
|
||||
into a packed-pixel image.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i21" class="rowColor">
|
||||
<tr id="i22" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setScalingFactor(org.libjpegturbo.turbojpeg.TJScalingFactor)">setScalingFactor</a></span>​(<a href="TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a> scalingFactor)</code></th>
|
||||
<td class="colLast">
|
||||
<div class="block">Set the scaling factor for subsequent lossy decompression operations.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i22" class="altColor">
|
||||
<tr id="i23" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage(byte%5B%5D,int)">setSourceImage</a></span>​(byte[] jpegImage,
|
||||
int imageSize)</code></th>
|
||||
@@ -429,7 +444,7 @@ implements java.io.Closeable</pre>
|
||||
<code>jpegImage</code> with this decompressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i23" class="rowColor">
|
||||
<tr id="i24" class="altColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSourceImage(org.libjpegturbo.turbojpeg.YUVImage)">setSourceImage</a></span>​(<a href="YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a> srcImage)</code></th>
|
||||
<td class="colLast">
|
||||
@@ -1218,6 +1233,61 @@ implements java.io.Closeable</pre>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>saveImage</h4>
|
||||
<pre class="methodSignature">public void saveImage​(java.lang.String fileName,
|
||||
java.lang.Object image,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int pitch,
|
||||
int height,
|
||||
int pixelFormat)
|
||||
throws <a href="TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></pre>
|
||||
<div class="block">Save a packed-pixel image with 2 to 16 bits of data precision per sample
|
||||
from memory to disk.</div>
|
||||
<dl>
|
||||
<dt><span class="paramLabel">Parameters:</span></dt>
|
||||
<dd><code>fileName</code> - name of a file to which to save the packed-pixel image.
|
||||
The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format,
|
||||
depending on the file extension. Windows BMP files require
|
||||
8-bit-per-sample data precision. When saving a PBMPLUS file, the source
|
||||
data precision (from 2 to 16 bits per sample) can be specified using
|
||||
<a href="TJ.html#PARAM_PRECISION"><code>TJ.PARAM_PRECISION</code></a> and defaults to 8 if <a href="TJ.html#PARAM_PRECISION"><code>TJ.PARAM_PRECISION</code></a>
|
||||
is unset.</dd>
|
||||
<dd><code>image</code> - buffer containing a packed-pixel RGB, grayscale, or CMYK
|
||||
image to be saved. The buffer is a <code>byte</code> array if the image
|
||||
has 2 to 8 bits of data precision per sample and a <code>short</code>
|
||||
array otherwise.</dd>
|
||||
<dd><code>x</code> - x offset (in pixels) of the region in the buffer from which to
|
||||
save the packed-pixel image</dd>
|
||||
<dd><code>y</code> - y offset (in pixels) of the region in the buffer from which to
|
||||
save the packed-pixel image</dd>
|
||||
<dd><code>width</code> - width (in pixels) of the region in the buffer from which to
|
||||
save the packed-pixel image</dd>
|
||||
<dd><code>pitch</code> - samples per row in the packed-pixel buffer. Setting this
|
||||
parameter to 0 is the equivalent of setting it to <code>width *
|
||||
<a href="TJ.html#getPixelSize(int)"><code>TJ.getPixelSize</code></a>(pixelFormat)</code>.</dd>
|
||||
<dd><code>height</code> - height (in pixels) of the region in the buffer from which to
|
||||
save the packed-pixel image</dd>
|
||||
<dd><code>pixelFormat</code> - pixel format of the packed-pixel image (one of
|
||||
<a href="TJ.html#PF_RGB"><code>TJ.PF_*</code></a>). If this parameter is set to
|
||||
<a href="TJ.html#PF_GRAY"><code>TJ.PF_GRAY</code></a>, then the image will be stored in PGM or
|
||||
8-bit-per-pixel (indexed color) BMP format. Otherwise, the image will be
|
||||
stored in PPM or 24-bit-per-pixel BMP format. If this parameter is set to
|
||||
<a href="TJ.html#PF_CMYK"><code>TJ.PF_CMYK</code></a>, then the CMYK pixels will be converted to RGB using a
|
||||
quick & dirty algorithm that is suitable only for testing purposes.
|
||||
(Proper conversion between CMYK and other formats requires a color
|
||||
management system.)</dd>
|
||||
<dt><span class="throwsLabel">Throws:</span></dt>
|
||||
<dd><code><a href="TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></code></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a id="close()">
|
||||
<!-- -->
|
||||
</a>
|
||||
|
||||
@@ -235,7 +235,7 @@ extends <a href="TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Methods inherited from class org.libjpegturbo.turbojpeg.<a href="TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></h3>
|
||||
<code><a href="TJDecompressor.html#close()">close</a>, <a href="TJDecompressor.html#decompress12(int,int)">decompress12</a>, <a href="TJDecompressor.html#decompress12(short%5B%5D,int,int,int,int)">decompress12</a>, <a href="TJDecompressor.html#decompress16(int,int)">decompress16</a>, <a href="TJDecompressor.html#decompress16(short%5B%5D,int,int,int,int)">decompress16</a>, <a href="TJDecompressor.html#decompress8(byte%5B%5D,int,int,int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int%5B%5D,int,int,int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(java.awt.image.BufferedImage)">decompress8</a>, <a href="TJDecompressor.html#decompressToYUV(int)">decompressToYUV</a>, <a href="TJDecompressor.html#decompressToYUV(int%5B%5D)">decompressToYUV</a>, <a href="TJDecompressor.html#decompressToYUV(org.libjpegturbo.turbojpeg.YUVImage)">decompressToYUV</a>, <a href="TJDecompressor.html#finalize()">finalize</a>, <a href="TJDecompressor.html#get(int)">get</a>, <a href="TJDecompressor.html#getHeight()">getHeight</a>, <a href="TJDecompressor.html#getJPEGBuf()">getJPEGBuf</a>, <a href="TJDecompressor.html#getJPEGSize()">getJPEGSize</a>, <a href="TJDecompressor.html#getWidth()">getWidth</a>, <a href="TJDecompressor.html#set(int,int)">set</a>, <a href="TJDecompressor.html#setCroppingRegion(java.awt.Rectangle)">setCroppingRegion</a>, <a href="TJDecompressor.html#setScalingFactor(org.libjpegturbo.turbojpeg.TJScalingFactor)">setScalingFactor</a>, <a href="TJDecompressor.html#setSourceImage(byte%5B%5D,int)">setSourceImage</a>, <a href="TJDecompressor.html#setSourceImage(org.libjpegturbo.turbojpeg.YUVImage)">setSourceImage</a></code></li>
|
||||
<code><a href="TJDecompressor.html#close()">close</a>, <a href="TJDecompressor.html#decompress12(int,int)">decompress12</a>, <a href="TJDecompressor.html#decompress12(short%5B%5D,int,int,int,int)">decompress12</a>, <a href="TJDecompressor.html#decompress16(int,int)">decompress16</a>, <a href="TJDecompressor.html#decompress16(short%5B%5D,int,int,int,int)">decompress16</a>, <a href="TJDecompressor.html#decompress8(byte%5B%5D,int,int,int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int%5B%5D,int,int,int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(int,int)">decompress8</a>, <a href="TJDecompressor.html#decompress8(java.awt.image.BufferedImage)">decompress8</a>, <a href="TJDecompressor.html#decompressToYUV(int)">decompressToYUV</a>, <a href="TJDecompressor.html#decompressToYUV(int%5B%5D)">decompressToYUV</a>, <a href="TJDecompressor.html#decompressToYUV(org.libjpegturbo.turbojpeg.YUVImage)">decompressToYUV</a>, <a href="TJDecompressor.html#finalize()">finalize</a>, <a href="TJDecompressor.html#get(int)">get</a>, <a href="TJDecompressor.html#getHeight()">getHeight</a>, <a href="TJDecompressor.html#getJPEGBuf()">getJPEGBuf</a>, <a href="TJDecompressor.html#getJPEGSize()">getJPEGSize</a>, <a href="TJDecompressor.html#getWidth()">getWidth</a>, <a href="TJDecompressor.html#saveImage(java.lang.String,java.lang.Object,int,int,int,int,int,int)">saveImage</a>, <a href="TJDecompressor.html#set(int,int)">set</a>, <a href="TJDecompressor.html#setCroppingRegion(java.awt.Rectangle)">setCroppingRegion</a>, <a href="TJDecompressor.html#setScalingFactor(org.libjpegturbo.turbojpeg.TJScalingFactor)">setScalingFactor</a>, <a href="TJDecompressor.html#setSourceImage(byte%5B%5D,int)">setSourceImage</a>, <a href="TJDecompressor.html#setSourceImage(org.libjpegturbo.turbojpeg.YUVImage)">setSourceImage</a></code></li>
|
||||
</ul>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -273,6 +273,13 @@ public final class TJ {
|
||||
* YCCK JPEG images into packed-pixel CMYK images.
|
||||
*/
|
||||
public static final int PF_CMYK = 11;
|
||||
/**
|
||||
* Unknown pixel format
|
||||
*
|
||||
* <p>Currently this is only used by
|
||||
* {@link TJCompressor#loadSourceImage TJCompressor.loadSourceImage()}.
|
||||
*/
|
||||
public static final int PF_UNKNOWN = -1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -516,7 +523,11 @@ public final class TJ {
|
||||
* Data precision (bits per sample)
|
||||
*
|
||||
* <p>The JPEG image uses (decompression) or will use (lossless compression)
|
||||
* the specified number of bits per sample.
|
||||
* the specified number of bits per sample. This parameter also specifies
|
||||
* the target data precision when loading a PBMPLUS file with
|
||||
* {@link TJCompressor#loadSourceImage TJCompressor.loadSourceImage()} and
|
||||
* the source data precision when saving a PBMPLUS file with
|
||||
* {@link TJDecompressor#saveImage TJDecompressor.saveImage()}.
|
||||
*
|
||||
* <p>The data precision is the number of bits in the maximum sample value,
|
||||
* which may not be the same as the width of the data type used to store the
|
||||
@@ -525,7 +536,7 @@ public final class TJ {
|
||||
* <p><b>Value</b>
|
||||
* <ul>
|
||||
* <li> <code>8</code> or <code>12</code> for lossy JPEG images;
|
||||
* <code>2</code> to <code>16</code> for lossless JPEG images
|
||||
* <code>2</code> to <code>16</code> for lossless JPEG and PBMPLUS images
|
||||
* </ul>
|
||||
*
|
||||
* <p>12-bit JPEG data precision implies {@link #PARAM_OPTIMIZE} unless
|
||||
@@ -819,7 +830,12 @@ public final class TJ {
|
||||
* </ul>
|
||||
*
|
||||
* <p>This value is stored in or read from the JPEG header. It does not
|
||||
* affect the contents of the JPEG image.
|
||||
* affect the contents of the JPEG image. Note that this parameter is set by
|
||||
* {@link TJCompressor#loadSourceImage TJCompressor.loadSourceImage()} when
|
||||
* loading a Windows BMP file that contains pixel density information, and
|
||||
* the value of this parameter is stored to a Windows BMP file by
|
||||
* {@link TJDecompressor#saveImage TJDecompressor.saveImage()} if the value
|
||||
* of {@link #PARAM_DENSITYUNITS} is <code>2</code>.
|
||||
*
|
||||
* @see #PARAM_DENSITYUNITS
|
||||
*/
|
||||
@@ -835,7 +851,12 @@ public final class TJ {
|
||||
* </ul>
|
||||
*
|
||||
* <p>This value is stored in or read from the JPEG header. It does not
|
||||
* affect the contents of the JPEG image.
|
||||
* affect the contents of the JPEG image. Note that this parameter is set by
|
||||
* {@link TJCompressor#loadSourceImage TJCompressor.loadSourceImage()} when
|
||||
* loading a Windows BMP file that contains pixel density information, and
|
||||
* the value of this parameter is stored to a Windows BMP file by
|
||||
* {@link TJDecompressor#saveImage TJDecompressor.saveImage()} if the value
|
||||
* of {@link #PARAM_DENSITYUNITS} is <code>2</code>.
|
||||
*
|
||||
* @see #PARAM_DENSITYUNITS
|
||||
*/
|
||||
@@ -856,7 +877,12 @@ public final class TJ {
|
||||
* </ul>
|
||||
*
|
||||
* <p>This value is stored in or read from the JPEG header. It does not
|
||||
* affect the contents of the JPEG image.
|
||||
* affect the contents of the JPEG image. Note that this parameter is set by
|
||||
* {@link TJCompressor#loadSourceImage TJCompressor.loadSourceImage()} when
|
||||
* loading a Windows BMP file that contains pixel density information, and
|
||||
* the value of this parameter is stored to a Windows BMP file by
|
||||
* {@link TJDecompressor#saveImage TJDecompressor.saveImage()} if the value
|
||||
* is <code>2</code>.
|
||||
*
|
||||
* @see #PARAM_XDENSITY
|
||||
* @see #PARAM_YDENSITY
|
||||
|
||||
@@ -39,6 +39,9 @@ import java.io.*;
|
||||
*/
|
||||
public class TJCompressor implements Closeable {
|
||||
|
||||
private static final String NO_ASSOC_ERROR =
|
||||
"No source image is associated with this instance";
|
||||
|
||||
/**
|
||||
* Create a TurboJPEG compressor instance.
|
||||
*/
|
||||
@@ -344,7 +347,7 @@ public class TJCompressor implements Closeable {
|
||||
if (intPixels) {
|
||||
SinglePixelPackedSampleModel sm =
|
||||
(SinglePixelPackedSampleModel)srcImage.getSampleModel();
|
||||
srcStride = sm.getScanlineStride();
|
||||
srcPitch = sm.getScanlineStride();
|
||||
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
||||
srcBufInt = db.getData();
|
||||
srcBuf8 = null;
|
||||
@@ -386,6 +389,149 @@ public class TJCompressor implements Closeable {
|
||||
srcBufInt = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a packed-pixel RGB or grayscale source image with 2 to 16 bits of
|
||||
* data precision per sample from disk into memory and associate it with this
|
||||
* compressor instance. Note that packed-pixel source images with 2 to 7, 9
|
||||
* to 11, or 13 to 16 bits of data precision per sample can only be
|
||||
* compressed into lossless JPEG images.
|
||||
*
|
||||
* <p>{@link #getWidth()}, {@link #getPitch()}, {@link #getHeight()},
|
||||
* {@link #getPixelFormat()}, and {@link #getSourceBuf()} can be used to
|
||||
* obtain the source image's dimensions, pixel format, and buffer after it is
|
||||
* loaded.
|
||||
*
|
||||
* @param fileName name of a file containing a packed-pixel image in Windows
|
||||
* BMP or PBMPLUS (PPM/PGM) format. Windows BMP files require
|
||||
* 8-bit-per-sample data precision. When loading a PBMPLUS file, the target
|
||||
* data precision (from 2 to 16 bits per sample) can be specified using
|
||||
* {@link TJ#PARAM_PRECISION} and defaults to 8 if {@link TJ#PARAM_PRECISION}
|
||||
* is unset. If the data precision of the PBMPLUS file does not match the
|
||||
* target data precision, then upconverting or downconverting will be
|
||||
* performed.
|
||||
*
|
||||
* @param align row alignment (in samples) of the packed-pixel buffer into
|
||||
* which the source image will be loaded (must be a power of 2.) Setting
|
||||
* this parameter to n will cause all rows in the buffer to be padded to the
|
||||
* nearest multiple of n samples (1 = unpadded.)
|
||||
*
|
||||
* @param pixelFormat pixel format of the packed-pixel buffer into which the
|
||||
* source image will be loaded. The behavior of this method varies depending
|
||||
* on the value of <code>pixelFormat</code>:
|
||||
* <ul>
|
||||
* <li> {@link TJ#PF_UNKNOWN} : The packed-pixel buffer created by this
|
||||
* method will use the most optimal pixel format for the file type. Use
|
||||
* {@link #getPixelFormat()} to obtain the ID of that pixel format.
|
||||
* <li> {@link TJ#PF_GRAY} : Only PGM files and 8-bit-per-pixel BMP files
|
||||
* with a grayscale colormap can be loaded.
|
||||
* <li> {@link TJ#PF_CMYK} : The RGB or grayscale pixels stored in the file
|
||||
* will be converted using a quick & dirty algorithm that is suitable
|
||||
* only for testing purposes. (Proper conversion between CMYK and other
|
||||
* formats requires a color management system.)
|
||||
* <li> Other {@link TJ#PF_RGB pixel formats} : The packed-pixel buffer
|
||||
* will use the specified pixel format, and pixel format conversion will be
|
||||
* performed if necessary.
|
||||
* </ul>
|
||||
*/
|
||||
public void loadSourceImage(String fileName, int align, int pixelFormat)
|
||||
throws TJException {
|
||||
int precision = get(TJ.PARAM_PRECISION);
|
||||
if (precision < 2 || precision > 16)
|
||||
precision = 8;
|
||||
Object srcBuf = loadSourceImage(precision, fileName, align, pixelFormat);
|
||||
if (precision <= 8)
|
||||
srcBuf8 = (byte[])srcBuf;
|
||||
else if (precision <= 12)
|
||||
srcBuf12 = (short[])srcBuf;
|
||||
else
|
||||
srcBuf16 = (short[])srcBuf;
|
||||
srcBufInt = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the source image (packed-pixel or YUV) associated
|
||||
* with this compressor instance.
|
||||
*
|
||||
* @return the width of the source image (packed-pixel or YUV) associated
|
||||
* with this compressor instance.
|
||||
*/
|
||||
public int getWidth() {
|
||||
if (srcYUVImage != null)
|
||||
return srcYUVImage.getWidth();
|
||||
if (srcWidth < 1)
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return srcWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pitch (samples per row) of the packed-pixel source image
|
||||
* associated with this compressor instance. If the source image is a
|
||||
* <code>BufferedImage</code> instance with integer pixels, then the stride
|
||||
* (pixels per row) is returned instead.
|
||||
*
|
||||
* @return the pitch (samples per row) of the packed-pixel source image
|
||||
* associated with this compressor instance.
|
||||
*/
|
||||
public int getPitch() {
|
||||
if (srcPitch < 1)
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return srcPitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the source image (packed-pixel or YUV) associated
|
||||
* with this compressor instance.
|
||||
*
|
||||
* @return the height of the source image (packed-pixel or YUV) associated
|
||||
* with this compressor instance.
|
||||
*/
|
||||
public int getHeight() {
|
||||
if (srcYUVImage != null)
|
||||
return srcYUVImage.getHeight();
|
||||
if (srcHeight < 1)
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return srcHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pixel format of the packed-pixel source image associated with
|
||||
* this compressor instance. The pixel format is one of
|
||||
* {@link TJ#PF_RGB TJ.PF_*}.
|
||||
*
|
||||
* @return the pixel format of the packed-pixel source image associated with
|
||||
* this compressor instance.
|
||||
*/
|
||||
public int getPixelFormat() {
|
||||
if (srcPixelFormat == TJ.PF_UNKNOWN)
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
return srcPixelFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the buffer containing the packed-pixel image associated with this
|
||||
* compressor instance. The buffer is a <code>byte</code> array if the
|
||||
* source image has 2 to 8 bits of data precision per sample, a
|
||||
* <code>short</code> array if the source image has 9 to 16 bits of data
|
||||
* precision per sample, and either a <code>byte</code> or an
|
||||
* <code>int</code> array (depending on the image type) if the source image
|
||||
* is a <code>BufferedImage</code> instance.
|
||||
*
|
||||
* @return the buffer containing the packed-pixel image associated with this
|
||||
* compressor instance.
|
||||
*/
|
||||
public Object getSourceBuf() {
|
||||
if (srcBuf8 != null)
|
||||
return srcBuf8;
|
||||
else if (srcBuf12 != null)
|
||||
return srcBuf12;
|
||||
else if (srcBuf16 != null)
|
||||
return srcBuf16;
|
||||
else if (srcBufInt != null)
|
||||
return srcBufInt;
|
||||
else
|
||||
throw new IllegalStateException(NO_ASSOC_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a compression parameter.
|
||||
*
|
||||
@@ -439,7 +585,7 @@ public class TJCompressor implements Closeable {
|
||||
compressedSize = compress16(srcBuf16, srcX, srcY, srcWidth, srcPitch,
|
||||
srcHeight, srcPixelFormat, dstBuf);
|
||||
else if (srcBufInt != null)
|
||||
compressedSize = compress8(srcBufInt, srcX, srcY, srcWidth, srcStride,
|
||||
compressedSize = compress8(srcBufInt, srcX, srcY, srcWidth, srcPitch,
|
||||
srcHeight, srcPixelFormat, dstBuf);
|
||||
else
|
||||
throw new IllegalStateException("No source image is associated with this instance");
|
||||
@@ -493,7 +639,7 @@ public class TJCompressor implements Closeable {
|
||||
set(TJ.PARAM_SUBSAMP, dstImage.getSubsamp());
|
||||
|
||||
if (srcBufInt != null) {
|
||||
encodeYUV8(srcBufInt, srcX, srcY, srcWidth, srcStride, srcHeight,
|
||||
encodeYUV8(srcBufInt, srcX, srcY, srcWidth, srcPitch, srcHeight,
|
||||
srcPixelFormat, dstImage.getPlanes(), dstImage.getOffsets(),
|
||||
dstImage.getStrides());
|
||||
} else {
|
||||
@@ -634,18 +780,8 @@ public class TJCompressor implements Closeable {
|
||||
int srcStride, int height, int pixelFormat, byte[][] dstPlanes,
|
||||
int[] dstOffsets, int[] dstStrides) throws TJException;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Ugly hack alert. It isn't straightforward to load 12-bit-per-sample and
|
||||
* 16-bit-per-sample images using the ImageIO and BufferedImage classes, and
|
||||
* ImageIO doesn't support PBMPLUS files anyhow. This method accesses
|
||||
* tj3LoadImage() through JNI and copies the pixel data between the C and
|
||||
* Java heaps. Currently it is undocumented and used only by TJBench.
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||
public native Object loadImage(int precision, String fileName, int[] width,
|
||||
int align, int[] height, int[] pixelFormat)
|
||||
throws TJException;
|
||||
private native Object loadSourceImage(int precision, String fileName,
|
||||
int align, int pixelFormat) throws TJException;
|
||||
|
||||
static {
|
||||
TJLoader.load();
|
||||
@@ -660,9 +796,8 @@ public class TJCompressor implements Closeable {
|
||||
private int srcHeight = 0;
|
||||
private int srcX = -1;
|
||||
private int srcY = -1;
|
||||
private int srcPitch = 0;
|
||||
private int srcStride = 0;
|
||||
private int srcPixelFormat = -1;
|
||||
private int srcPitch = -1;
|
||||
private int srcPixelFormat = TJ.PF_UNKNOWN;
|
||||
private YUVImage srcYUVImage = null;
|
||||
private int compressedSize = 0;
|
||||
private ByteOrder byteOrder = null;
|
||||
|
||||
@@ -861,6 +861,59 @@ public class TJDecompressor implements Closeable {
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a packed-pixel image with 2 to 16 bits of data precision per sample
|
||||
* from memory to disk.
|
||||
*
|
||||
* @param fileName name of a file to which to save the packed-pixel image.
|
||||
* The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format,
|
||||
* depending on the file extension. Windows BMP files require
|
||||
* 8-bit-per-sample data precision. When saving a PBMPLUS file, the source
|
||||
* data precision (from 2 to 16 bits per sample) can be specified using
|
||||
* {@link TJ#PARAM_PRECISION} and defaults to 8 if {@link TJ#PARAM_PRECISION}
|
||||
* is unset.
|
||||
*
|
||||
* @param image buffer containing a packed-pixel RGB, grayscale, or CMYK
|
||||
* image to be saved. The buffer is a <code>byte</code> array if the image
|
||||
* has 2 to 8 bits of data precision per sample and a <code>short</code>
|
||||
* array otherwise.
|
||||
*
|
||||
* @param x x offset (in pixels) of the region in the buffer from which to
|
||||
* save the packed-pixel image
|
||||
*
|
||||
* @param y y offset (in pixels) of the region in the buffer from which to
|
||||
* save the packed-pixel image
|
||||
*
|
||||
* @param width width (in pixels) of the region in the buffer from which to
|
||||
* save the packed-pixel image
|
||||
*
|
||||
* @param pitch samples per row in the packed-pixel buffer. Setting this
|
||||
* parameter to 0 is the equivalent of setting it to <code>width *
|
||||
* {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat)</code>.
|
||||
*
|
||||
* @param height height (in pixels) of the region in the buffer from which to
|
||||
* save the packed-pixel image
|
||||
*
|
||||
* @param pixelFormat pixel format of the packed-pixel image (one of
|
||||
* {@link TJ#PF_RGB TJ.PF_*}). If this parameter is set to
|
||||
* {@link TJ#PF_GRAY}, then the image will be stored in PGM or
|
||||
* 8-bit-per-pixel (indexed color) BMP format. Otherwise, the image will be
|
||||
* stored in PPM or 24-bit-per-pixel BMP format. If this parameter is set to
|
||||
* {@link TJ#PF_CMYK}, then the CMYK pixels will be converted to RGB using a
|
||||
* quick & dirty algorithm that is suitable only for testing purposes.
|
||||
* (Proper conversion between CMYK and other formats requires a color
|
||||
* management system.)
|
||||
*/
|
||||
public void saveImage(String fileName, Object image, int x, int y, int width,
|
||||
int pitch, int height, int pixelFormat)
|
||||
throws TJException {
|
||||
int precision = get(TJ.PARAM_PRECISION);
|
||||
if (precision < 2 || precision > 16)
|
||||
precision = 8;
|
||||
saveImage(precision, fileName, image, x, y, width, pitch, height,
|
||||
pixelFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the native structures associated with this decompressor instance.
|
||||
*/
|
||||
@@ -923,18 +976,9 @@ public class TJDecompressor implements Closeable {
|
||||
int[] srcStrides, int[] dstBuf, int x, int y, int width, int stride,
|
||||
int height, int pixelFormat) throws TJException;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Ugly hack alert. It isn't straightforward to save 12-bit-per-sample and
|
||||
* 16-bit-per-sample images using the ImageIO and BufferedImage classes, and
|
||||
* ImageIO doesn't support PBMPLUS files anyhow. This method accesses
|
||||
* tj3SaveImage() through JNI and copies the pixel data between the C and
|
||||
* Java heaps. Currently it is undocumented and used only by TJBench.
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||
public native void saveImage(int precision, String fileName, Object srcBuf,
|
||||
int width, int pitch, int height,
|
||||
int pixelFormat) throws TJException;
|
||||
private native void saveImage(int precision, String fileName, Object buffer,
|
||||
int x, int y, int width, int pitch, int height, int pixelFormat)
|
||||
throws TJException;
|
||||
|
||||
static {
|
||||
TJLoader.load();
|
||||
|
||||
@@ -51,6 +51,8 @@ extern "C" {
|
||||
#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_PF_UNKNOWN
|
||||
#define org_libjpegturbo_turbojpeg_TJ_PF_UNKNOWN -1L
|
||||
#undef org_libjpegturbo_turbojpeg_TJ_NUMCS
|
||||
#define org_libjpegturbo_turbojpeg_TJ_NUMCS 5L
|
||||
#undef org_libjpegturbo_turbojpeg_TJ_CS_RGB
|
||||
|
||||
@@ -97,11 +97,11 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV8__
|
||||
|
||||
/*
|
||||
* Class: org_libjpegturbo_turbojpeg_TJCompressor
|
||||
* Method: loadImage
|
||||
* Signature: (ILjava/lang/String;[II[I[I)Ljava/lang/Object;
|
||||
* Method: loadSourceImage
|
||||
* Signature: (ILjava/lang/String;II)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadImage
|
||||
(JNIEnv *, jobject, jint, jstring, jintArray, jint, jintArray, jintArray);
|
||||
JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadSourceImage
|
||||
(JNIEnv *, jobject, jint, jstring, jint, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV8
|
||||
/*
|
||||
* Class: org_libjpegturbo_turbojpeg_TJDecompressor
|
||||
* Method: saveImage
|
||||
* Signature: (ILjava/lang/String;Ljava/lang/Object;IIII)V
|
||||
* Signature: (ILjava/lang/String;Ljava/lang/Object;IIIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_saveImage
|
||||
(JNIEnv *, jobject, jint, jstring, jobject, jint, jint, jint, jint);
|
||||
(JNIEnv *, jobject, jint, jstring, jobject, jint, jint, jint, jint, jint, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1270,35 +1270,25 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy
|
||||
}
|
||||
|
||||
/* Private image I/O routines (used only by TJBench) */
|
||||
JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadImage
|
||||
(JNIEnv *env, jobject obj, jint precision, jstring jfilename,
|
||||
jintArray jwidth, jint align, jintArray jheight, jintArray jpixelFormat)
|
||||
JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadSourceImage
|
||||
(JNIEnv *env, jobject obj, jint precision, jstring jfilename, jint align,
|
||||
jint pixelFormat)
|
||||
{
|
||||
tjhandle handle = NULL;
|
||||
void *dstBuf = NULL, *jdstPtr;
|
||||
int width, *warr, height, *harr, pixelFormat, *pfarr;
|
||||
int width, height;
|
||||
jsize arraySize, pitch;
|
||||
const char *filename = NULL;
|
||||
jboolean isCopy;
|
||||
jobject jdstBuf = NULL;
|
||||
jfieldID fid;
|
||||
jclass cls;
|
||||
|
||||
GET_HANDLE();
|
||||
|
||||
if (precision < 2 || precision > 16 || jfilename == NULL || jwidth == NULL ||
|
||||
(*env)->GetArrayLength(env, jwidth) < 1 || jheight == NULL ||
|
||||
(*env)->GetArrayLength(env, jheight) < 1 || jpixelFormat == NULL ||
|
||||
(*env)->GetArrayLength(env, jpixelFormat) < 1)
|
||||
if (precision < 2 || precision > 16 || jfilename == NULL)
|
||||
THROW_ARG("Invalid argument in loadImage()");
|
||||
|
||||
BAILIF0NOEC(warr = (*env)->GetPrimitiveArrayCritical(env, jwidth, 0));
|
||||
width = warr[0];
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jwidth, warr, 0);
|
||||
BAILIF0NOEC(harr = (*env)->GetPrimitiveArrayCritical(env, jheight, 0));
|
||||
height = harr[0];
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jheight, harr, 0);
|
||||
BAILIF0NOEC(pfarr = (*env)->GetPrimitiveArrayCritical(env, jpixelFormat, 0));
|
||||
pixelFormat = pfarr[0];
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jpixelFormat, pfarr, 0);
|
||||
BAILIF0(filename = (*env)->GetStringUTFChars(env, jfilename, &isCopy));
|
||||
|
||||
if (precision <= 8) {
|
||||
@@ -1323,17 +1313,17 @@ JNIEXPORT jobject JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_loadImage
|
||||
(unsigned long long)((unsigned int)-1))
|
||||
THROW_ARG("Image is too large");
|
||||
|
||||
BAILIF0NOEC(warr = (*env)->GetPrimitiveArrayCritical(env, jwidth, 0));
|
||||
warr[0] = width;
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jwidth, warr, 0);
|
||||
BAILIF0NOEC(harr = (*env)->GetPrimitiveArrayCritical(env, jheight, 0));
|
||||
harr[0] = height;
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jheight, harr, 0);
|
||||
BAILIF0NOEC(pfarr = (*env)->GetPrimitiveArrayCritical(env, jpixelFormat, 0));
|
||||
pfarr[0] = pixelFormat;
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jpixelFormat, pfarr, 0);
|
||||
|
||||
cls = (*env)->GetObjectClass(env, obj);
|
||||
BAILIF0(fid = (*env)->GetFieldID(env, cls, "srcWidth", "I"));
|
||||
(*env)->SetIntField(env, obj, fid, width);
|
||||
BAILIF0(fid = (*env)->GetFieldID(env, cls, "srcPitch", "I"));
|
||||
pitch = PAD(width * tjPixelSize[pixelFormat], align);
|
||||
(*env)->SetIntField(env, obj, fid, pitch);
|
||||
BAILIF0(fid = (*env)->GetFieldID(env, cls, "srcHeight", "I"));
|
||||
(*env)->SetIntField(env, obj, fid, height);
|
||||
BAILIF0(fid = (*env)->GetFieldID(env, cls, "srcPixelFormat", "I"));
|
||||
(*env)->SetIntField(env, obj, fid, pixelFormat);
|
||||
|
||||
arraySize = pitch * height;
|
||||
if (precision <= 8)
|
||||
jdstBuf = (*env)->NewByteArray(env, arraySize);
|
||||
@@ -1352,10 +1342,11 @@ bailout:
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_saveImage
|
||||
(JNIEnv *env, jobject obj, jint precision, jstring jfilename,
|
||||
jobject jsrcBuf, jint width, jint pitch, jint height, jint pixelFormat)
|
||||
jobject jbuffer, jint x, jint y, jint width, jint pitch, jint height,
|
||||
jint pf)
|
||||
{
|
||||
tjhandle handle = NULL;
|
||||
void *srcBuf = NULL, *jsrcPtr;
|
||||
void *buffer = NULL;
|
||||
const char *filename = NULL;
|
||||
jsize arraySize, actualPitch;
|
||||
jboolean isCopy;
|
||||
@@ -1363,44 +1354,52 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_saveImage
|
||||
GET_HANDLE();
|
||||
|
||||
if (precision < 2 || precision > 16 || jfilename == NULL ||
|
||||
jsrcBuf == NULL || width < 1 || pitch < 0 || height < 1 ||
|
||||
pixelFormat < 0 || pixelFormat >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
|
||||
jbuffer == NULL || x < 0 || y < 0 || width < 1 || pitch < 0 ||
|
||||
height < 1 || pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
|
||||
THROW_ARG("Invalid argument in saveImage()");
|
||||
if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF)
|
||||
THROW_ARG("Mismatch between Java and C API");
|
||||
|
||||
if ((unsigned long long)width * (unsigned long long)height *
|
||||
(unsigned long long)tjPixelSize[pixelFormat] >
|
||||
(unsigned long long)tjPixelSize[pf] >
|
||||
(unsigned long long)((unsigned int)-1))
|
||||
THROW_ARG("Image is too large");
|
||||
actualPitch = (pitch == 0) ? width * tjPixelSize[pixelFormat] : pitch;
|
||||
actualPitch = (pitch == 0) ? width * tjPixelSize[pf] : pitch;
|
||||
arraySize = actualPitch * height;
|
||||
if ((*env)->GetArrayLength(env, jsrcBuf) < arraySize)
|
||||
if ((*env)->GetArrayLength(env, jbuffer) < arraySize)
|
||||
THROW_ARG("Source buffer is not large enough");
|
||||
|
||||
if ((srcBuf = malloc(arraySize * (precision > 8 ? 2 : 1))) == NULL)
|
||||
THROW_MEM();
|
||||
|
||||
BAILIF0NOEC(jsrcPtr = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
|
||||
memcpy(srcBuf, jsrcPtr, arraySize * (precision > 8 ? 2 : 1));
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jsrcBuf, jsrcPtr, 0);
|
||||
BAILIF0NOEC(buffer = (*env)->GetPrimitiveArrayCritical(env, jbuffer, 0));
|
||||
BAILIF0(filename = (*env)->GetStringUTFChars(env, jfilename, &isCopy));
|
||||
|
||||
if (precision <= 8) {
|
||||
if (tj3SaveImage8(handle, filename, srcBuf, width, pitch, height,
|
||||
pixelFormat) == -1)
|
||||
if (tj3SaveImage8(handle, filename,
|
||||
&((unsigned char *)buffer)[y * actualPitch +
|
||||
x * tjPixelSize[pf]], width,
|
||||
pitch, height, pf) == -1) {
|
||||
SAFE_RELEASE(jbuffer, buffer);
|
||||
THROW_TJ();
|
||||
}
|
||||
} else if (precision <= 12) {
|
||||
if (tj3SaveImage12(handle, filename, srcBuf, width, pitch, height,
|
||||
pixelFormat) == -1)
|
||||
if (tj3SaveImage12(handle, filename,
|
||||
&((short *)buffer)[y * actualPitch +
|
||||
x * tjPixelSize[pf]], width, pitch,
|
||||
height, pf) == -1) {
|
||||
SAFE_RELEASE(jbuffer, buffer);
|
||||
THROW_TJ();
|
||||
}
|
||||
} else {
|
||||
if (tj3SaveImage16(handle, filename, srcBuf, width, pitch, height,
|
||||
pixelFormat) == -1)
|
||||
if (tj3SaveImage16(handle, filename,
|
||||
&((unsigned short *)buffer)[y * actualPitch +
|
||||
x * tjPixelSize[pf]], width,
|
||||
pitch, height, pf) == -1) {
|
||||
SAFE_RELEASE(jbuffer, buffer);
|
||||
THROW_TJ();
|
||||
}
|
||||
}
|
||||
|
||||
bailout:
|
||||
SAFE_RELEASE(jbuffer, buffer);
|
||||
if (filename) (*env)->ReleaseStringUTFChars(env, jfilename, filename);
|
||||
free(srcBuf);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user