Class 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); //75 is default
     encoder.write(bufferedImage, outputStream);
     
    • Constructor Detail

      • JpegEncoder

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

        public JpegEncoder()
    • Method Detail

      • getEncoderOptions

        public com.idrsolutions.image.jpeg.options.JpegEncoderOptions getEncoderOptions()
      • 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 jpegEncoderOptions.setQuality(int percentage); setEncoderOptions(jpegEncoderOptions);
      • getQuality

        @Deprecated
        public int getQuality()
        Deprecated.
        - use getEncoderOptions().getQuality();