Streamline Java wrapper
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@424 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/java/TJExample.java b/java/TJExample.java
index b4acf1b..3362e81 100644
--- a/java/TJExample.java
+++ b/java/TJExample.java
@@ -78,10 +78,12 @@
fis.read(inputbuf);
fis.close();
- TJDecompressor tjd=new TJDecompressor();
- TJHeaderInfo tji=tjd.decompressHeader(inputbuf, inputsize);
- System.out.print("Source Image: "+tji.width+" x "+tji.height+ " pixels, ");
- switch(tji.subsamp) {
+ TJDecompressor tjd=new TJDecompressor(inputbuf);
+ int width=tjd.getWidth();
+ int height=tjd.getHeight();
+ int subsamp=tjd.getSubsamp();
+ System.out.print("Source Image: "+width+" x "+height+" pixels, ");
+ switch(subsamp) {
case TJ.SAMP444: System.out.println("4:4:4 subsampling"); break;
case TJ.SAMP422: System.out.println("4:2:2 subsampling"); break;
case TJ.SAMP420: System.out.println("4:2:0 subsampling"); break;
@@ -90,22 +92,18 @@
}
if(scalefactor!=1) {
- tji.width=(tji.width+scalefactor-1)/scalefactor;
- tji.height=(tji.height+scalefactor-1)/scalefactor;
- System.out.println("Dest. Image: "+tji.width+" x "+tji.height
+ width=(width+scalefactor-1)/scalefactor;
+ height=(height+scalefactor-1)/scalefactor;
+ System.out.println("Dest. Image: "+width+" x "+height
+" pixels");
}
-
- byte [] tmpbuf=new byte[tji.width*tji.height*3];
- tjd.decompress(inputbuf, inputsize, tmpbuf, tji.width, tji.width*3,
- tji.height, 3, TJ.BOTTOMUP);
+ byte [] tmpbuf=tjd.decompress(width, 0, height, TJ.BGR, TJ.BOTTOMUP);
tjd.close();
- TJCompressor tjc=new TJCompressor();
- byte [] outputbuf=new byte[(int)TJ.bufSize(tji.width, tji.height)];
- long outputsize=tjc.compress(tmpbuf, tji.width, tji.width*3, tji.height,
- 3, outputbuf, tji.subsamp, 95, TJ.BOTTOMUP);
+ TJCompressor tjc=new TJCompressor(tmpbuf, width, 0, height, TJ.BGR);
+ byte [] outputbuf=new byte[(int)TJ.bufSize(width, height)];
+ long outputsize=tjc.compress(outputbuf, subsamp, 95, TJ.BOTTOMUP);
tjc.close();
file=new File(argv[1]);