diff options
author | Peter Hancock <phancock@apache.org> | 2012-04-12 14:17:05 +0000 |
---|---|---|
committer | Peter Hancock <phancock@apache.org> | 2012-04-12 14:17:05 +0000 |
commit | 37ff704262a892e22100b9e56c40228c5bcf562d (patch) | |
tree | b4ef2cee049b55b39f02366dc2a3b66b2745a50b | |
parent | 03f65a7b8b6d294cff0a6888b466e72da83fead2 (diff) | |
download | xmlgraphics-fop-37ff704262a892e22100b9e56c40228c5bcf562d.tar.gz xmlgraphics-fop-37ff704262a892e22100b9e56c40228c5bcf562d.zip |
Bugzilla#49893: A global setting to wrap F11 images in page segments.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1325277 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 142 insertions, 20 deletions
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index 9b6a3edc9..8597ab787 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -797,6 +797,17 @@ Note that the value of the encoding attribute in the example is the double-byte <source><![CDATA[ <images mode="b+w" bits-per-pixel="1" dithering-quality="maximum"/>]]></source> <p> + When the boolean attribute pseg (default false) is set to true, non-inline FS11 and FS45 IOCA images are wrapped in page segment. + This option is provided to support printers/print servers that require this MO:DCA structure. + </p> + <source><![CDATA[ + <images mode="b+w" bits-per-pixel="8" pseg="true"/>]]></source> + <p> + Setting the boolean attribute fs45 to true (default false) will force all images to FS45. + </p> + <source><![CDATA[ + <images mode="b+w" bits-per-pixel="8" fs45="true"/>]]></source> + <p> By default, JPEG images are rasterized to a bitmap and the bitmap is included in the AFP doc. However it is possible to encode in a lossless way to maintain maximum quality. But due to lack of support for compression schemes like LZW (patent concerns), bitmap data is currently diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java index 1c87b27d2..7e6b940a5 100644 --- a/src/java/org/apache/fop/afp/AFPPaintingState.java +++ b/src/java/org/apache/fop/afp/AFPPaintingState.java @@ -84,6 +84,13 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState /** determines whether to stroke text in GOCA mode or to use text operators where possible */ private boolean strokeGocaText = false; + + /** use page segment with F11 and F45 images*/ + private boolean pSeg; + + /** use FS45 images*/ + private boolean fs45; + /** the current page */ private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState(); @@ -356,6 +363,41 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState return this.strokeGocaText; } + /** + * Whether FS11 and SF45 non-inline images should be wrapped in a page segment + * @return true iff images should be wrapped + */ + public boolean getWrapPSeg() { + return pSeg; + } + + /** + * Sets whether FS11 and FS45 non-inline images should be wrapped in a page segment + * @param pSeg true iff images should be wrapped + */ + public void setWrapPSeg(boolean pSeg) { + this.pSeg = pSeg; + } + + + /** + * gets whether images should be FS45 + * @return true iff images should be FS45 + */ + public boolean getFS45() { + return fs45; + } + + /** + * sets whether images should be FS45 + * @param fs45 true iff images should be FS45 + */ + public void setFS45(boolean fs45) { + this.fs45 = fs45; + } + + + /** {@inheritDoc} */ @Override protected AbstractData instantiateData() { diff --git a/src/java/org/apache/fop/afp/modca/ImageObject.java b/src/java/org/apache/fop/afp/modca/ImageObject.java index c6cfa3808..adb56e626 100644 --- a/src/java/org/apache/fop/afp/modca/ImageObject.java +++ b/src/java/org/apache/fop/afp/modca/ImageObject.java @@ -75,10 +75,11 @@ public class ImageObject extends AbstractDataObject { int dataHeightRes = imageObjectInfo.getDataWidthRes(); ImageDataDescriptor imageDataDescriptor = factory.createImageDataDescriptor(dataWidth, dataHeight, dataWidthRes, dataHeightRes); - if (imageObjectInfo.getBitsPerPixel() == 1) { - imageDataDescriptor.setFunctionSet(ImageDataDescriptor.FUNCTION_SET_FS10); - } else if (MimeConstants.MIME_AFP_IOCA_FS45.equals(imageObjectInfo.getMimeType())) { + + if (MimeConstants.MIME_AFP_IOCA_FS45.equals(imageObjectInfo.getMimeType())) { imageDataDescriptor.setFunctionSet(ImageDataDescriptor.FUNCTION_SET_FS45); + } else if (imageObjectInfo.getBitsPerPixel() == 1) { + imageDataDescriptor.setFunctionSet(ImageDataDescriptor.FUNCTION_SET_FS10); } getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor); getObjectEnvironmentGroup().setMapImageObject( diff --git a/src/java/org/apache/fop/render/afp/AFPCustomizable.java b/src/java/org/apache/fop/render/afp/AFPCustomizable.java index 684ac057c..6eca86458 100644 --- a/src/java/org/apache/fop/render/afp/AFPCustomizable.java +++ b/src/java/org/apache/fop/render/afp/AFPCustomizable.java @@ -90,6 +90,30 @@ public interface AFPCustomizable { void setResolution(int resolution); /** + * Sets whether FS11 and FS45 non-inline images should be wrapped in a page segment + * @param pSeg true iff images should be wrapped + */ + void setWrapPSeg(boolean pSeg); + + /** + * set true if images should be FS45 + * @param fs45 true iff images should be FS45 + */ + void setFS45(boolean fs45); + + /** + * gets whether FS11 and FS45 non-inline images should be wrapped in a page segment + * @return true iff images should be wrapped + */ + boolean getWrapPSeg(); + + /** + * gets whether images should be FS45 + * @return true iff images should be FS45 + */ + boolean getFS45(); + + /** * Returns the output/device resolution. * * @return the resolution in dpi diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java index cddcc7b84..0c778303c 100644 --- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java @@ -468,6 +468,26 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler } /** {@inheritDoc} */ + public void setWrapPSeg(boolean pSeg) { + paintingState.setWrapPSeg(pSeg); + } + + /** {@inheritDoc} */ + public void setFS45(boolean fs45) { + paintingState.setFS45(fs45); + } + + /** {@inheritDoc} */ + public boolean getWrapPSeg() { + return paintingState.getWrapPSeg(); + } + + /** {@inheritDoc} */ + public boolean getFS45() { + return paintingState.getFS45(); + } + + /** {@inheritDoc} */ public void setDefaultResourceGroupFilePath(String filePath) { resourceManager.setDefaultResourceGroupFilePath(filePath); } diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java index 0b4b6ea98..e5f41d232 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java @@ -149,6 +149,25 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima private static final class RenderedImageEncoder { + private enum FunctionSet { + + FS10(MimeConstants.MIME_AFP_IOCA_FS10), + FS11(MimeConstants.MIME_AFP_IOCA_FS11), + FS45(MimeConstants.MIME_AFP_IOCA_FS45); + + private String mimeType; + + FunctionSet(String mimeType) { + this.mimeType = mimeType; + } + + private String getMimeType() { + return mimeType; + } + }; + + + private ImageRendered imageRendered; private Dimension targetSize; @@ -223,7 +242,7 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima throws IOException { RenderedImage renderedImage = imageRendered.getRenderedImage(); - int functionSet = useFS10 ? 10 : 11; + FunctionSet functionSet = useFS10 ? FunctionSet.FS10 : FunctionSet.FS11; if (usePageSegments) { assert resampledDim != null; @@ -285,7 +304,7 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima log.debug("Encoding image directly..."); imageObjectInfo.setBitsPerPixel(encodedColorModel.getPixelSize()); if (pixelSize == 32) { - functionSet = 45; //IOCA FS45 required for CMYK + functionSet = FunctionSet.FS45; //IOCA FS45 required for CMYK } //Lossy or loss-less? @@ -315,23 +334,17 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima log.debug("Encoding image via RGB..."); imageData = encodeViaRGB(renderedImage, imageObjectInfo, paintingState, baos); } - - switch (functionSet) { - case 10: - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS10); - break; - case 11: - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS11); - break; - case 45: - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); - break; - default: - throw new IllegalStateException("Invalid IOCA function set: " + functionSet); + // Should image be FS45? + if (paintingState.getFS45()) { + functionSet = FunctionSet.FS45; } - + //Wrapping 300+ resolution FS11 IOCA in a page segment is apparently necessary(?) + imageObjectInfo.setCreatePageSegment( + (functionSet.equals(FunctionSet.FS11) || functionSet.equals(FunctionSet.FS45)) + && paintingState.getWrapPSeg() + ); + imageObjectInfo.setMimeType(functionSet.getMimeType()); imageObjectInfo.setData(imageData); - return imageObjectInfo; } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 23449ce4e..bf7fbde4a 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -415,6 +415,14 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator customizable.canEmbedJpeg(allowEmbedding); customizable.setBitmapEncodingQuality(ieq); + //FS11 and FS45 page segment wrapping + boolean pSeg = imagesCfg.getAttributeAsBoolean("pseg", false); + customizable.setWrapPSeg(pSeg); + + //FS45 image forcing + boolean fs45 = imagesCfg.getAttributeAsBoolean("fs45", false); + customizable.setFS45(fs45); + // shading (filled rectangles) Configuration shadingCfg = cfg.getChild("shading"); AFPShadingMode shadingMode = AFPShadingMode.valueOf( diff --git a/status.xml b/status.xml index 9cb50efbd..105b80fbd 100644 --- a/status.xml +++ b/status.xml @@ -62,6 +62,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> <release version="FOP Trunk" date="TBD"> + <action context="Code" dev="PH" type="add" fixes-bug="49893"> + A global setting to wrap F11 images in page segments. + </action> <action context="Code" dev="GA" type="fix" fixes-bug="52763"> Support list-block in marker, thus preventing NPE. </action> |