From 7d4b0016657ecdf8803ccbaf6358f0e67063624d Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 4 Mar 2011 13:40:42 +0000 Subject: [PATCH] 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 --- java/TJExample.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 @@ public class TJExample { } 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 @@ public class TJExample { } 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 @@ public class TJExample { + " 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; -- 2.40.0