Class Jpeg2000Encoder

  • All Implemented Interfaces:
    com.idrsolutions.image.Encoder

    public class Jpeg2000Encoder
    extends com.idrsolutions.image.JDeliImage
    implements com.idrsolutions.image.Encoder
    Class writes BufferedImages as JPEG2000

    Example:

    
     Jpeg2000Encoder encoder = new Jpeg2000Encoder();
     //encoder.setQuality(75);
     encoder.write(bufferedImage, outputStream);
     
    • Constructor Detail

      • Jpeg2000Encoder

        public Jpeg2000Encoder()
    • Method Detail

      • write

        public void write​(BufferedImage image,
                          File file)
                   throws IOException
        Writes BufferedImage as JPEG2000 to a file
        Parameters:
        image - BufferedImage The image to write
        file - The output file to write to
        Throws:
        IOException - if the image wasn't written
      • write

        public void write​(BufferedImage image,
                          OutputStream os)
                   throws IOException
        Writes BufferedImage as JPEG2000 to an OutputStream

        This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

        Specified by:
        write in interface com.idrsolutions.image.Encoder
        Parameters:
        image - BufferedImage The image to write
        os - The stream to write to
        Throws:
        IOException - if the image wasn't written
      • setQuality

        public void setQuality​(int quality)
        Set the image quality level for JPEG2000 output. The quality level can be between 1 - 100 and if not set defaults to 50. Higher quality produces better quality JPEG2000 files but increases output data size.

        For lossless encoding set the quality level to 100

        Parameters:
        quality - Quality level to set for JPEG2000 output
      • getQuality

        public int getQuality()
        Retrieve the image quality level for JPEG2000 output. The quality level can be between 1 - 100 and if not set defaults to 50. Higher quality produces better quality JPEG2000 files but increases output data size.
        Returns:
        Quality level used for JPEG2000 output