org.libjpegturbo.turbojpeg

## Class TJTransformer

- java.lang.Object
- - org.libjpegturbo.turbojpeg.TJDecompressor
  - - org.libjpegturbo.turbojpeg.TJTransformer

-     public class TJTransformer
      extends TJDecompressor

  TurboJPEG lossless transformer

- - ### Field Summary

    - ### Fields inherited from class org.libjpegturbo.turbojpeg.TJDecompressor

      `handle, jpegBuf, jpegBufSize, jpegColorspace, jpegHeight, jpegSubsamp, jpegWidth, yuvImage`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TJTransformer()` Create a TurboJPEG lossless transformer instance.
    `TJTransformer(byte[] jpegImage)` Create a TurboJPEG lossless transformer instance and associate the JPEG image stored in `jpegImage` with the newly created instance.
    `TJTransformer(byte[] jpegImage, int imageSize)` Create a TurboJPEG lossless transformer instance and associate the JPEG image of length `imageSize` bytes stored in `jpegImage` with the newly created instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int[]` | `getTransformedSizes()` Returns an array containing the sizes of the transformed JPEG images generated by the most recent transform operation.
    `void` | `transform(byte[][] dstBufs, TJTransform[] transforms, int flags)` Losslessly transform the JPEG image associated with this transformer instance into one or more JPEG images stored in the given destination buffers.
    `TJDecompressor[]` | `transform(TJTransform[] transforms, int flags)` Losslessly transform the JPEG image associated with this transformer instance and return an array of `TJDecompressor` instances, each of which has a transformed JPEG image associated with it.

    - ### Methods inherited from class org.libjpegturbo.turbojpeg.TJDecompressor

      `close, decompress, decompress, decompress, decompress, decompress, decompress, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, finalize, getColorspace, getHeight, getJPEGBuf, getJPEGSize, getScaledHeight, getScaledWidth, getSubsamp, getWidth, setJPEGImage, setSourceImage, setSourceImage`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TJTransformer

          public TJTransformer()
                        throws java.lang.Exception

      Create a TurboJPEG lossless transformer instance.
      Throws:
        `java.lang.Exception`

    - #### TJTransformer

          public TJTransformer(byte[] jpegImage)
                        throws java.lang.Exception

      Create a TurboJPEG lossless transformer instance and associate the JPEG image stored in `jpegImage` with the newly created instance.
      Parameters:
        `jpegImage` - JPEG image buffer (size of the JPEG image is assumed to be the length of the array)
      Throws:
        `java.lang.Exception`

    - #### TJTransformer

          public TJTransformer(byte[] jpegImage,
                       int imageSize)
                        throws java.lang.Exception

      Create a TurboJPEG lossless transformer instance and associate the JPEG image of length `imageSize` bytes stored in `jpegImage` with the newly created instance.
      Parameters:
        `jpegImage` - JPEG image buffer
        `imageSize` - size of the JPEG image (in bytes)
      Throws:
        `java.lang.Exception`

  - ### Method Detail

    - #### transform

          public void transform(byte[][] dstBufs,
                       TJTransform[] transforms,
                       int flags)
                         throws java.lang.Exception

      Losslessly transform the JPEG image associated with this transformer instance into one or more JPEG images stored in the given destination buffers. Lossless transforms work by moving the raw coefficients from one JPEG image structure to another without altering the values of the coefficients. While this is typically faster than decompressing the image, transforming it, and re-compressing it, lossless transforms are not free. Each lossless transform requires reading and performing Huffman decoding on all of the coefficients in the source image, regardless of the size of the destination image. Thus, this method provides a means of generating multiple transformed images from the same source or of applying multiple transformations simultaneously, in order to eliminate the need to read the source coefficients multiple times.
      Parameters:
        `dstBufs` - an array of image buffers. `dstbufs[i]` will receive a JPEG image that has been transformed using the parameters in `transforms[i]`. Use `TJ.bufSize(int, int, int)` to determine the maximum size for each buffer based on the transformed or cropped width and height and the level of subsampling used in the source image.
        `transforms` - an array of `TJTransform` instances, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image
        `flags` - the bitwise OR of one or more of `TJ.FLAG_*`
      Throws:
        `java.lang.Exception`

    - #### transform

          public TJDecompressor[] transform(TJTransform[] transforms,
                                   int flags)
                                     throws java.lang.Exception

      Losslessly transform the JPEG image associated with this transformer instance and return an array of `TJDecompressor` instances, each of which has a transformed JPEG image associated with it.
      Parameters:
        `transforms` - an array of `TJTransform` instances, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image
        `flags` - the bitwise OR of one or more of `TJ.FLAG_*`
      Returns:
        an array of `TJDecompressor` instances, each of which has a transformed JPEG image associated with it.
      Throws:
        `java.lang.Exception`

    - #### getTransformedSizes

          public int[] getTransformedSizes()
                                    throws java.lang.Exception

      Returns an array containing the sizes of the transformed JPEG images generated by the most recent transform operation.
      Returns:
        an array containing the sizes of the transformed JPEG images generated by the most recent transform operation.
      Throws:
        `java.lang.Exception`