* @return An appropriate compression filter, or null if no compression should be used.
* @exception GraphicException For error reading Graphic file.
*/
private PsEncodeFilter getFilter(final OutputStream outputStream) throws GraphicException {
final PsServer psServer = this.getPDFDocument().getPsServer();
PsEncodeFilter filter = null;
final Graphic graphic = this.getGraphic();
if (graphic.getGraphicType() == Graphic.Type.JPEG) {
filter = psServer.makeEncodeFilter(PsFilterType.DCT, outputStream);
filter.setInactive();
return filter;
}
if (graphic.getGraphicType() == Graphic.Type.TIFF) {
final Graphic.Compression imageCompression
= graphic.getCompressionType();
switch (imageCompression) {
case UNCOMPRESSED:
return null;
case CCITT_GROUP_3:
filter = psServer.makeEncodeFilter(PsFilterType.CCITT_FAX, outputStream);
filter.setInactive();
return filter;
case CCITT_GROUP_4:
filter = psServer.makeEncodeFilter(PsFilterType.CCITT_FAX, outputStream);
filter.setInactive();
filter.setDecodeParms("<< /K -1 /Columns " + graphic.pixelWidth() + " >>");
return filter;
case JPEG:
filter = psServer.makeEncodeFilter(PsFilterType.DCT, outputStream);
filter.setInactive();
return filter;
default:
throw new GraphicException("Error while loading image "
+ graphic.getUrl() + " : "
+ this.getClass() + " - "