Package com.idrsolutions.image.png
Class PngEncoder
java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.png.PngEncoder
- All Implemented Interfaces:
com.idrsolutions.image.Encoder
public class PngEncoder
extends com.idrsolutions.image.JDeliImage
implements com.idrsolutions.image.Encoder
Class writes BufferedImages as Fast deflated Png
Example 1:
PngEncoder encoder = new PngEncoder();
encoder.write(image, outputStream);
Example 2 (with 8 bit quantisation compression):
PngEncoder encoder = new PngEncoder();
encoder.getEncoderOptions().setCompressionFormat(PngCompressionFormat.QUANTISED8BIT);
encoder.write(image, outputStream);
-
Field Summary
Fields inherited from class com.idrsolutions.image.JDeliImage
bb
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.boolean
Deprecated.- usegetEncoderOptions().isOptimizeBasedOnColors();
void
setCompressed
(boolean compress) Deprecated.- usevoid
setEncoderOptions
(PngEncoderOptions pngEncoderOptions) void
setOptimizeBasedOnColors
(boolean optimizeBasedOnColors) Deprecated.- usevoid
write
(BufferedImage image, File file) Writes BufferedImage as a PNG into a filevoid
write
(BufferedImage image, OutputStream outputStream) Writes BufferedImage as a PNG into an OutputStreamMethods inherited from class com.idrsolutions.image.JDeliImage
optimiseImage
-
Constructor Details
-
PngEncoder
public PngEncoder(com.idrsolutions.image.encoder.options.EncoderOptions format) -
PngEncoder
public PngEncoder()
-
-
Method Details
-
write
Writes BufferedImage as a PNG into an OutputStreamThis 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 interfacecom.idrsolutions.image.Encoder
- Parameters:
image
- BufferedImage to writeoutputStream
- The stream to write the image to- Throws:
IOException
- if an error occurs when trying to write the image
-
write
Writes BufferedImage as a PNG into a file- Parameters:
image
- BufferedImage to writefile
- The file to write the image to- Throws:
IOException
- if an error occurs when trying to write the image
-
isCompressed
Deprecated.- usegetEncoderOptions().getCompressionFormat().equals(PngCompressionFormat.QUANTISED8BIT);
Returns whether 8 bit quantisation compression is set in PNG generation- Returns:
- Whether compression is enabled
-
getEncoderOptions
- Specified by:
getEncoderOptions
in interfacecom.idrsolutions.image.Encoder
-
setEncoderOptions
-
setCompressed
Deprecated.- usepngEncoderOptions.setCompressionFormat(PngCompressionFormat pngCompression); setEncoderOptions(pngEncoderOptions);
Set true to enable 8 bit quantisation compression in PNG generation- Parameters:
compress
- value to determine if compression used
-
isOptimizeBasedOnColors
Deprecated.- usegetEncoderOptions().isOptimizeBasedOnColors();
- Returns:
- Whether compression feature is enabled
-
setOptimizeBasedOnColors
Deprecated.- usepngEncoderOptions.setOptimizeBasedOnColors(boolean); setEncoderOptions(pngEncoderOptions);
- Parameters:
optimizeBasedOnColors
- value to determine strategy of image optimisation
-
getEncoderOptions().getCompressionFormat().equals(PngCompressionFormat.QUANTISED8BIT);