Browse Source

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
tags/fop-1_1rc1old
Peter Hancock 12 years ago
parent
commit
37ff704262

+ 11
- 0
src/documentation/content/xdocs/trunk/output.xml View File

@@ -796,6 +796,17 @@ Note that the value of the encoding attribute in the example is the double-byte
</p>
<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

+ 42
- 0
src/java/org/apache/fop/afp/AFPPaintingState.java View File

@@ -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() {

+ 4
- 3
src/java/org/apache/fop/afp/modca/ImageObject.java View File

@@ -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(

+ 24
- 0
src/java/org/apache/fop/render/afp/AFPCustomizable.java View File

@@ -89,6 +89,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.
*

+ 20
- 0
src/java/org/apache/fop/render/afp/AFPDocumentHandler.java View File

@@ -467,6 +467,26 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
return this.paintingState.isStrokeGOCAText();
}

/** {@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);

+ 30
- 17
src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java View File

@@ -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;
}


+ 8
- 0
src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java View File

@@ -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(

+ 3
- 0
status.xml View File

@@ -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>

Loading…
Cancel
Save