Implement YUV encode/decode methods at the Java level; Remove some of the arguments from the Java API and replace with get/set methods; General API cleanup; Fix BufferedImage grayscale tests in TJUnitTest
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@451 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/java/TJExample.java b/java/TJExample.java
index 238bc2f..fc4cb6b 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -150,10 +150,8 @@
height = (height + scaleFactor - 1)/scaleFactor;
}
- if(!outFormat.equalsIgnoreCase("jpg")) {
- img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- tjd.decompress(img, 0);
- }
+ if(!outFormat.equalsIgnoreCase("jpg"))
+ img = tjd.decompress(width, height, BufferedImage.TYPE_INT_RGB, 0);
else bmpBuf = tjd.decompress(width, 0, height, TJ.PF_BGRX, 0);
tjd.close();
}
@@ -175,14 +173,17 @@
+ " subsampling, quality = " + outQual);
TJCompressor tjc = new TJCompressor();
int jpegSize;
- byte [] jpegBuf = new byte[TJ.bufSize(width, height)];
+ byte [] jpegBuf;
+ tjc.setSubsamp(outSubsamp);
+ tjc.setJPEGQuality(outQual);
if(img != null)
- jpegSize = tjc.compress(img, jpegBuf, outSubsamp, outQual, 0);
+ jpegBuf = tjc.compress(img, 0);
else {
tjc.setBitmapBuffer(bmpBuf, width, 0, height, TJ.PF_BGRX);
- jpegSize = tjc.compress(jpegBuf, outSubsamp, outQual, 0);
+ jpegBuf = tjc.compress(0);
}
+ jpegSize = tjc.getCompressedSize();
tjc.close();
file = new File(argv[1]);