Index: src/java/org/apache/fop/render/afp/AFPDocumentHandler.java =================================================================== --- src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (revision 1055079) +++ src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (working copy) @@ -385,6 +385,26 @@ } /** {@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); } Index: src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java =================================================================== --- src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (revision 1055079) +++ src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (working copy) @@ -394,6 +394,14 @@ boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false); customizable.setNativeImagesSupported(nativeImageSupport); + //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( Index: src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java =================================================================== --- src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java (revision 1055079) +++ src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java (working copy) @@ -66,11 +66,27 @@ ImageFlavor.RENDERED_IMAGE }; - private AFPDataObjectInfo updateDataObjectInfo // CSOK: MethodLength - (AFPImageObjectInfo imageObjectInfo, - AFPPaintingState paintingState, ImageRendered imageRendered, Dimension targetSize) - throws IOException { + 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 AFPDataObjectInfo updateDataObjectInfo(AFPImageObjectInfo imageObjectInfo, + AFPPaintingState paintingState, ImageRendered imageRendered, Dimension targetSize) + throws IOException { + long start = System.currentTimeMillis(); int resolution = paintingState.getResolution(); @@ -89,7 +105,7 @@ ImageSize intrinsicSize = imageInfo.getSize(); boolean useFS10 = (maxPixelSize == 1) || BitmapImageUtil.isMonochromeImage(renderedImage); - int functionSet = useFS10 ? 10 : 11; + FunctionSet functionSet = useFS10 ? FunctionSet.FS10 : FunctionSet.FS11; boolean usePageSegments = useFS10 && !imageObjectInfo.getResourceInfo().getLevel().isInline(); @@ -172,7 +188,7 @@ 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 } helper.encode(baos); @@ -207,20 +223,19 @@ } } - 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); // set object area info Index: src/java/org/apache/fop/render/afp/AFPCustomizable.java =================================================================== --- src/java/org/apache/fop/render/afp/AFPCustomizable.java (revision 1055079) +++ src/java/org/apache/fop/render/afp/AFPCustomizable.java (working copy) @@ -80,6 +80,30 @@ 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 Index: src/java/org/apache/fop/afp/modca/ImageObject.java =================================================================== --- src/java/org/apache/fop/afp/modca/ImageObject.java (revision 1055079) +++ src/java/org/apache/fop/afp/modca/ImageObject.java (working copy) @@ -76,10 +76,11 @@ int dataHeightRes = imageObjectInfo.getDataWidthRes(); ImageDataDescriptor imageDataDescriptor = factory.createImageDataDescriptor(dataWidth, dataHeight, dataWidthRes, dataHeightRes); - if (imageObjectInfo.getBitsPerPixel() == 1) { + + 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); - } else if (MimeConstants.MIME_AFP_IOCA_FS45.equals(imageObjectInfo.getMimeType())) { - imageDataDescriptor.setFunctionSet(ImageDataDescriptor.FUNCTION_SET_FS45); } getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor); getObjectEnvironmentGroup().setMapImageObject( Index: src/java/org/apache/fop/afp/AFPPaintingState.java =================================================================== --- src/java/org/apache/fop/afp/AFPPaintingState.java (revision 1055079) +++ src/java/org/apache/fop/afp/AFPPaintingState.java (working copy) @@ -73,6 +73,13 @@ /** the output resolution */ private int resolution = 240; // 240 dpi + + /** 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(); @@ -276,6 +283,41 @@ return this.resolution; } + /** + * 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} */ protected AbstractData instantiateData() { return new AFPData(); Index: src/documentation/content/xdocs/trunk/output.xml =================================================================== --- src/documentation/content/xdocs/trunk/output.xml (revision 1055079) +++ src/documentation/content/xdocs/trunk/output.xml (working copy) @@ -783,6 +783,16 @@
++ 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. +
+ ++ Setting the boolean attribute fs45 to true (default false) will force all images to FS45. +
+