diff --git a/ChangeLog.txt b/ChangeLog.txt index e1069f5ec..65e64de04 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -17,7 +17,8 @@ try-with-resources statement. [4] The TurboJPEG Java classes now throw unchecked idiomatic exceptions (IllegalArgumentException, IllegalStateException) for unrecoverable errors -caused by incorrect API usage. +caused by incorrect API usage, and those classes throw a new checked exception +type (TJException) for errors that are passed through from the C library. 1.4.1 diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index f9f9e572c..0af8ae155 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -5,6 +5,7 @@ set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ org/libjpegturbo/turbojpeg/TJCompressor org/libjpegturbo/turbojpeg/TJCustomFilter org/libjpegturbo/turbojpeg/TJDecompressor + org/libjpegturbo/turbojpeg/TJException org/libjpegturbo/turbojpeg/TJScalingFactor org/libjpegturbo/turbojpeg/TJTransform org/libjpegturbo/turbojpeg/TJTransformer diff --git a/java/Makefile.am b/java/Makefile.am index 23e341294..475dd3feb 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -10,6 +10,7 @@ JAVASOURCES = org/libjpegturbo/turbojpeg/TJ.java \ org/libjpegturbo/turbojpeg/TJCompressor.java \ org/libjpegturbo/turbojpeg/TJCustomFilter.java \ org/libjpegturbo/turbojpeg/TJDecompressor.java \ + org/libjpegturbo/turbojpeg/TJException.java \ org/libjpegturbo/turbojpeg/TJScalingFactor.java \ org/libjpegturbo/turbojpeg/TJTransform.java \ org/libjpegturbo/turbojpeg/TJTransformer.java \ @@ -31,6 +32,7 @@ JAVA_CLASSES = org/libjpegturbo/turbojpeg/TJ.class \ org/libjpegturbo/turbojpeg/TJCompressor.class \ org/libjpegturbo/turbojpeg/TJCustomFilter.class \ org/libjpegturbo/turbojpeg/TJDecompressor.class \ + org/libjpegturbo/turbojpeg/TJException.class \ org/libjpegturbo/turbojpeg/TJLoader.class \ org/libjpegturbo/turbojpeg/TJScalingFactor.class \ org/libjpegturbo/turbojpeg/TJTransform.class \ diff --git a/java/TJExample.java b/java/TJExample.java index 756211435..da0980789 100644 --- a/java/TJExample.java +++ b/java/TJExample.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2012, 2014 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2012, 2014-2015 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -351,7 +351,7 @@ else if (argv[i].length() > 2 && public void customFilter(ShortBuffer coeffBuffer, Rectangle bufferRegion, Rectangle planeRegion, int componentIndex, int transformIndex, TJTransform transform) - throws Exception { + throws TJException { for (int i = 0; i < bufferRegion.width * bufferRegion.height; i++) { coeffBuffer.put(i, (short)(-coeffBuffer.get(i))); } diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html index 509ea5084..fecac06d0 100644 --- a/java/doc/allclasses-frame.html +++ b/java/doc/allclasses-frame.html @@ -13,6 +13,7 @@

All Classes

  • TJCompressor
  • TJCustomFilter
  • TJDecompressor
  • +
  • TJException
  • TJScalingFactor
  • TJTransform
  • TJTransformer
  • diff --git a/java/doc/allclasses-noframe.html b/java/doc/allclasses-noframe.html index 3eac18fa1..1f7fd3c6b 100644 --- a/java/doc/allclasses-noframe.html +++ b/java/doc/allclasses-noframe.html @@ -13,6 +13,7 @@

    All Classes

  • TJCompressor
  • TJCustomFilter
  • TJDecompressor
  • +
  • TJException
  • TJScalingFactor
  • TJTransform
  • TJTransformer
  • diff --git a/java/doc/index-all.html b/java/doc/index-all.html index 1af78bed7..a02d9c460 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -821,6 +821,16 @@

    T

    source image stored in yuvImage with the newly created instance. +
    TJException - Exception in org.libjpegturbo.turbojpeg
    +
     
    +
    TJException() - Constructor for exception org.libjpegturbo.turbojpeg.TJException
    +
     
    +
    TJException(String, Throwable) - Constructor for exception org.libjpegturbo.turbojpeg.TJException
    +
     
    +
    TJException(String) - Constructor for exception org.libjpegturbo.turbojpeg.TJException
    +
     
    +
    TJException(Throwable) - Constructor for exception org.libjpegturbo.turbojpeg.TJException
    +
     
    TJScalingFactor - Class in org.libjpegturbo.turbojpeg
    Fractional scaling factor
    diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html index 3ff9b89df..ffef65786 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html @@ -1075,16 +1075,13 @@

    getBlueOffset

    bufSize

    public static int bufSize(int width,
               int height,
    -          int jpegSubsamp)
    -                   throws java.lang.Exception
    + int jpegSubsamp)
    Returns the maximum size of the buffer (in bytes) required to hold a JPEG image with the given width, height, and level of chrominance subsampling.
    Parameters:
    width - the width (in pixels) of the JPEG image
    height - the height (in pixels) of the JPEG image
    jpegSubsamp - the level of chrominance subsampling to be used when generating the JPEG image (one of TJ.SAMP_*)
    Returns:
    the maximum size of the buffer (in bytes) required to hold a JPEG - image with the given width, height, and level of chrominance subsampling.
    -
    Throws:
    -
    java.lang.Exception
    + image with the given width, height, and level of chrominance subsampling.
    @@ -1096,17 +1093,14 @@

    bufSizeYUV

    public static int bufSizeYUV(int width,
                  int pad,
                  int height,
    -             int subsamp)
    -                      throws java.lang.Exception
    + int subsamp)
    Returns the size of the buffer (in bytes) required to hold a YUV planar image with the given width, height, and level of chrominance subsampling.
    Parameters:
    width - the width (in pixels) of the YUV image
    pad - the width of each line in each plane of the image is padded to the nearest multiple of this number of bytes (must be a power of 2.)
    height - the height (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
    Returns:
    the size of the buffer (in bytes) required to hold a YUV planar - image with the given width, height, and level of chrominance subsampling.
    -
    Throws:
    -
    java.lang.Exception
    + image with the given width, height, and level of chrominance subsampling. @@ -1118,11 +1112,8 @@

    bufSizeYUV

    @Deprecated
     public static int bufSizeYUV(int width,
                             int height,
    -                        int subsamp)
    -                      throws java.lang.Exception
    + int subsamp)
    Deprecated. Use bufSizeYUV(int, int, int, int) instead.
    -
    Throws:
    -
    java.lang.Exception
    @@ -1135,8 +1126,7 @@

    planeSizeYUV

    int width, int stride, int height, - int subsamp) - throws java.lang.Exception + int subsamp)
    Returns the size of the buffer (in bytes) required to hold a YUV image plane with the given parameters.
    Parameters:
    componentID - ID number of the image plane (0 = Y, 1 = U/Cb, @@ -1145,9 +1135,7 @@

    planeSizeYUV

    height of the whole image, not the plane height.
    subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
    Returns:
    the size of the buffer (in bytes) required to hold a YUV planar - image with the given parameters.
    -
    Throws:
    -
    java.lang.Exception
    + image with the given parameters. @@ -1158,16 +1146,13 @@

    planeSizeYUV

    planeWidth

    public static int planeWidth(int componentID,
                  int width,
    -             int subsamp)
    -                      throws java.lang.Exception
    + int subsamp)
    Returns the plane width of a YUV image plane with the given parameters. Refer to YUVImage for a description of plane width.
    Parameters:
    componentID - ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
    width - width (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
    -
    Returns:
    the plane width of a YUV image plane with the given parameters.
    -
    Throws:
    -
    java.lang.Exception
    +
    Returns:
    the plane width of a YUV image plane with the given parameters.
    @@ -1178,16 +1163,13 @@

    planeWidth

    planeHeight

    public static int planeHeight(int componentID,
                   int height,
    -              int subsamp)
    -                       throws java.lang.Exception
    + int subsamp)
    Returns the plane height of a YUV image plane with the given parameters. Refer to YUVImage for a description of plane height.
    Parameters:
    componentID - ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
    height - height (in pixels) of the YUV image
    subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
    -
    Returns:
    the plane height of a YUV image plane with the given parameters.
    -
    Throws:
    -
    java.lang.Exception
    +
    Returns:
    the plane height of a YUV image plane with the given parameters.
    @@ -1196,14 +1178,11 @@

    planeHeight

    diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index 9fe4f995e..29f12b79d 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -381,10 +381,10 @@

    Constructor Detail

  • TJCompressor

    public TJCompressor()
    -             throws java.lang.Exception
    + throws TJException
    Create a TurboJPEG compressor instance.
    Throws:
    -
    java.lang.Exception
    +
    TJException
  • @@ -400,14 +400,14 @@

    TJCompressor

    int pitch, int height, int pixelFormat) - throws java.lang.Exception + throws
    TJException
    Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created instance.
    Parameters:
    srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for description
    x - see setSourceImage(byte[], int, int, int, int, int, int) for description
    y - see setSourceImage(byte[], int, int, int, int, int, int) for description
    width - see setSourceImage(byte[], int, int, int, int, int, int) for description
    pitch - see setSourceImage(byte[], int, int, int, int, int, int) for description
    height - see setSourceImage(byte[], int, int, int, int, int, int) for description
    pixelFormat - pixel format of the source image (one of TJ.PF_*)
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -422,11 +422,11 @@

    TJCompressor

    int pitch, int height, int pixelFormat) - throws java.lang.Exception + throws
    TJException
    Deprecated. Use TJCompressor(byte[], int, int, int, int, int, int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -440,7 +440,7 @@

    TJCompressor

    int y, int width, int height) - throws java.lang.Exception + throws
    TJException
    Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly created instance.
    @@ -451,7 +451,7 @@

    TJCompressor

    setSourceImage(BufferedImage, int, int, int, int) for description
    height - see setSourceImage(BufferedImage, int, int, int, int) for description
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -475,7 +475,7 @@

    setSourceImage

    int pitch, int height, int pixelFormat) - throws java.lang.Exception + throws TJException
    Associate an uncompressed RGB, grayscale, or CMYK source image with this compressor instance.
    Parameters:
    srcImage - image buffer containing RGB, grayscale, or CMYK pixels to @@ -493,7 +493,7 @@

    setSourceImage

    which the JPEG or YUV image should be compressed/encoded
    pixelFormat - pixel format of the source image (one of TJ.PF_*)
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -508,11 +508,11 @@

    setSourceImage

    int pitch, int height, int pixelFormat) - throws java.lang.Exception + throws
    TJException
    Deprecated. Use setSourceImage(byte[], int, int, int, int, int, int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -526,7 +526,7 @@

    setSourceImage

    int y, int width, int height) - throws java.lang.Exception + throws
    TJException
    Associate an uncompressed RGB or grayscale source image with this compressor instance.
    Parameters:
    srcImage - a BufferedImage instance containing RGB or @@ -538,7 +538,7 @@

    setSourceImage

    which the JPEG or YUV image should be compressed/encoded (0 = use the height of the source image)
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -548,13 +548,13 @@

    setSourceImage

  • setSourceImage

    public void setSourceImage(YUVImage srcImage)
    -                    throws java.lang.Exception
    + throws TJException
    Associate an uncompressed YUV planar source image with this compressor instance.
    Parameters:
    srcImage - YUV planar image to be compressed. This image is not modified.
    Throws:
    -
    java.lang.Exception
    +
    TJException
  • @@ -604,7 +604,7 @@

    setJPEGQuality

    compress

    public void compress(byte[] dstBuf,
                 int flags)
    -              throws java.lang.Exception
    + throws
    TJException
    Compress the uncompressed source image associated with this compressor instance and output a JPEG image to the given destination buffer.
    Parameters:
    dstBuf - buffer that will receive the JPEG image. Use @@ -613,7 +613,7 @@

    compress

    subsampling.
    flags - the bitwise OR of one or more of TJ.FLAG_*
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -623,7 +623,7 @@

    compress

  • compress

    public byte[] compress(int flags)
    -                throws java.lang.Exception
    + throws
    TJException
    Compress the uncompressed source image associated with this compressor instance and return a buffer containing a JPEG image.
    Parameters:
    flags - the bitwise OR of one or more of @@ -631,7 +631,7 @@

    compress

    Returns:
    a buffer containing a JPEG image. The length of this buffer will not be equal to the size of the JPEG image. Use getCompressedSize() to obtain the size of the JPEG image.
    Throws:
    -
    java.lang.Exception
    +
    TJException
  • @@ -644,12 +644,12 @@

    compress

    public void compress(java.awt.image.BufferedImage srcImage, byte[] dstBuf, int flags) - throws java.lang.Exception + throws
    TJException
    Deprecated. Use setSourceImage(BufferedImage, int, int, int, int) and compress(byte[], int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -661,12 +661,12 @@

    compress

    @Deprecated
     public byte[] compress(java.awt.image.BufferedImage srcImage,
                              int flags)
    -                throws java.lang.Exception
    + throws
    TJException
    Deprecated. Use setSourceImage(BufferedImage, int, int, int, int) and compress(int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -677,7 +677,7 @@

    compress

    encodeYUV

    public void encodeYUV(YUVImage dstImage,
                  int flags)
    -               throws java.lang.Exception
    + throws TJException
    Encode the uncompressed source image associated with this compressor instance into a YUV planar image and store it in the given YUVImage instance. This method uses the accelerated color @@ -688,7 +688,7 @@

    encodeYUV

    image
    flags - the bitwise OR of one or more of TJ.FLAG_*
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -700,10 +700,10 @@

    encodeYUV

    @Deprecated
     public void encodeYUV(byte[] dstBuf,
                             int flags)
    -               throws java.lang.Exception
    + throws
    TJException
    Deprecated. Use encodeYUV(YUVImage, int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -714,7 +714,7 @@

    encodeYUV

    encodeYUV

    public YUVImage encodeYUV(int pad,
                      int flags)
    -                   throws java.lang.Exception
    + throws TJException
    Encode the uncompressed source image associated with this compressor instance into a unified YUV planar image buffer and return a YUVImage instance containing the encoded image. This method @@ -727,7 +727,7 @@

    encodeYUV

    TJ.FLAG_*
    Returns:
    a YUV planar image.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -738,7 +738,7 @@

    encodeYUV

    encodeYUV

    public YUVImage encodeYUV(int[] strides,
                      int flags)
    -                   throws java.lang.Exception
    + throws TJException
    Encode the uncompressed source image associated with this compressor instance into separate Y, U (Cb), and V (Cr) image planes and return a YUVImage instance containing the encoded image planes. This @@ -755,7 +755,7 @@

    encodeYUV

    TJ.FLAG_*
    Returns:
    a YUV planar image.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -766,10 +766,10 @@

    encodeYUV

    encodeYUV

    @Deprecated
     public byte[] encodeYUV(int flags)
    -                 throws java.lang.Exception
    + throws
    TJException
    Deprecated. Use encodeYUV(int, int) instead.
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -782,12 +782,12 @@

    encodeYUV

    public void encodeYUV(java.awt.image.BufferedImage srcImage, byte[] dstBuf, int flags) - throws java.lang.Exception + throws
    TJException
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -799,12 +799,12 @@

    encodeYUV

    @Deprecated
     public byte[] encodeYUV(java.awt.image.BufferedImage srcImage,
                               int flags)
    -                 throws java.lang.Exception
    + throws
    TJException
    Throws:
    -
    java.lang.Exception
    +
    TJException
    @@ -827,7 +827,7 @@

    getCompressedSize

  • close

    public void close()
    -           throws java.io.IOException
    + throws
    TJException
    Free the native structures associated with this compressor instance.
    Specified by:
    @@ -835,7 +835,7 @@

    close

    Specified by:
    close in interface java.lang.AutoCloseable
    Throws:
    -
    java.io.IOException
    +
    TJException
  • diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html index c2b6e6139..6bd6fd271 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html @@ -144,7 +144,7 @@

    customFilter

    int componentID, int transformID,
    TJTransform transform) - throws java.lang.Exception + throws TJException
    A callback function that can be used to modify the DCT coefficients after they are losslessly transformed but before they are transcoded to a new JPEG image. This allows for custom filters or other transformations to be @@ -165,7 +165,7 @@

    customFilter

    transform in the transforms array that was passed to TJTransformer.transform().
    transform - a TJTransform instance that specifies the parameters and/or cropping region for this transform
    Throws:
    -
    java.lang.Exception
    +
    TJException
    diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index 6cec2cc21..a914de9e0 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -33,7 +33,7 @@