Class JpegEncoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.jpeg.JpegEncoder
All Implemented Interfaces:
com.idrsolutions.image.Encoder

public class JpegEncoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Encoder
Class writes BufferedImages as Baseline JPEGs

Example:


          JpegEncoder encoder = new JpegEncoder();
          encoder.getEncoderOptions().setQuality(75); //50 is default
          encoder.write(bufferedImage, outputStream);
      
  • Constructor Details

    • JpegEncoder

      public JpegEncoder(com.idrsolutions.image.encoder.options.EncoderOptions format)
    • JpegEncoder

      public JpegEncoder()
  • Method Details

    • getEncoderOptions

      public JpegEncoderOptions getEncoderOptions()
      Specified by:
      getEncoderOptions in interface com.idrsolutions.image.Encoder
    • write

      public void write(BufferedImage image, OutputStream out) throws IOException
      Writes BufferedImage as Baseline JPEG 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
      out - The stream to write to
      Throws:
      IOException - if the image wasn't written
    • setQuality

      @Deprecated public void setQuality(int percentage)
      Deprecated.
      - use
      
                getEncoderOptions().setQuality(int percentage);
            
      Parameters:
      percentage - value used for image compression
      See Also:
    • getQuality

      @Deprecated public int getQuality()
      Deprecated.
      - use
      
                    getEncoderOptions().getQuality();
                
      Returns:
      value used for image compression