diff options
Diffstat (limited to 'java/org/libjpegturbo/turbojpeg/TJTransformer.java')
-rw-r--r-- | java/org/libjpegturbo/turbojpeg/TJTransformer.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransformer.java b/java/org/libjpegturbo/turbojpeg/TJTransformer.java index 2e173445..d76647fd 100644 --- a/java/org/libjpegturbo/turbojpeg/TJTransformer.java +++ b/java/org/libjpegturbo/turbojpeg/TJTransformer.java @@ -1,5 +1,6 @@ /* * Copyright (C)2011, 2013-2015 D. R. Commander. All Rights Reserved. + * Copyright (C)2015 Viktor Szathmáry. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -36,7 +37,7 @@ public class TJTransformer extends TJDecompressor { /** * Create a TurboJPEG lossless transformer instance. */ - public TJTransformer() throws Exception { + public TJTransformer() throws TJException { init(); } @@ -47,7 +48,7 @@ public class TJTransformer extends TJDecompressor { * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to * be the length of the array.) This buffer is not modified. */ - public TJTransformer(byte[] jpegImage) throws Exception { + public TJTransformer(byte[] jpegImage) throws TJException { init(); setSourceImage(jpegImage, jpegImage.length); } @@ -61,7 +62,7 @@ public class TJTransformer extends TJDecompressor { * * @param imageSize size of the JPEG image (in bytes) */ - public TJTransformer(byte[] jpegImage, int imageSize) throws Exception { + public TJTransformer(byte[] jpegImage, int imageSize) throws TJException { init(); setSourceImage(jpegImage, imageSize); } @@ -94,9 +95,9 @@ public class TJTransformer extends TJDecompressor { * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public void transform(byte[][] dstBufs, TJTransform[] transforms, - int flags) throws Exception { + int flags) throws TJException { if (jpegBuf == null) - throw new Exception("JPEG buffer not initialized"); + throw new IllegalStateException("JPEG buffer not initialized"); transformedSizes = transform(jpegBuf, jpegBufSize, dstBufs, transforms, flags); } @@ -117,10 +118,10 @@ public class TJTransformer extends TJDecompressor { * {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*} */ public TJDecompressor[] transform(TJTransform[] transforms, int flags) - throws Exception { + throws TJException { byte[][] dstBufs = new byte[transforms.length][]; if (jpegWidth < 1 || jpegHeight < 1) - throw new Exception("JPEG buffer not initialized"); + throw new IllegalStateException("JPEG buffer not initialized"); for (int i = 0; i < transforms.length; i++) { int w = jpegWidth, h = jpegHeight; if ((transforms[i].options & TJTransform.OPT_CROP) != 0) { @@ -143,20 +144,20 @@ public class TJTransformer extends TJDecompressor { * @return an array containing the sizes of the transformed JPEG images * generated by the most recent transform operation. */ - public int[] getTransformedSizes() throws Exception { + public int[] getTransformedSizes() { if (transformedSizes == null) - throw new Exception("No image has been transformed yet"); + throw new IllegalStateException("No image has been transformed yet"); return transformedSizes; } - private native void init() throws Exception; + private native void init() throws TJException; private native int[] transform(byte[] srcBuf, int srcSize, byte[][] dstBufs, - TJTransform[] transforms, int flags) throws Exception; + TJTransform[] transforms, int flags) throws TJException; static { TJLoader.load(); } private int[] transformedSizes = null; -}; +} |