If transforming and outputting a JPEG file, output the transformed file directly instead of decompressing/recompressing it
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@505 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/java/TJExample.java b/java/TJExample.java
index 4718db0..7f4d3d5 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -80,7 +80,7 @@
}
private final static String sampName[] = {
- "4:4:4", "4:2:2", "4:2:0", "Grayscale"
+ "4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0"
};
public static void main(String argv[]) {
@@ -122,8 +122,7 @@
}
if(match != 1) usage();
}
- if(argv[i].substring(0, 2).equalsIgnoreCase("-h")
- || argv[i].equalsIgnoreCase("-?"))
+ if(argv[i].equalsIgnoreCase("-h") || argv[i].equalsIgnoreCase("-?"))
usage();
if(argv[i].length() > 2
&& argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
@@ -220,6 +219,15 @@
+ " pixels, " + sampName[inSubsamp] + " subsampling");
if(outSubsamp < 0) outSubsamp = inSubsamp;
+ if(outFormat.equalsIgnoreCase("jpg") && (xform.op != TJ.XFORM_NONE
+ || xform.options != 0)) {
+ file = new File(argv[1]);
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(tjd.getJPEGBuf(), 0, tjd.getJPEGSize());
+ fos.close();
+ System.exit(0);
+ }
+
if(scaleNum != 1 || scaleDenom != 1) {
width = (width * scaleNum + scaleDenom - 1) / scaleDenom;
height = (height * scaleNum + scaleDenom - 1) / scaleDenom;