You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2007/12/17 20:05:42 UTC
svn commit: r604971 - in
/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps:
ImageFormGenerator.java PSImageUtils.java
Author: jeremias
Date: Mon Dec 17 11:05:41 2007
New Revision: 604971
URL: http://svn.apache.org/viewvc?rev=604971&view=rev
Log:
Need the BitPerComponent parameter for CCITT images.
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java?rev=604971&r1=604970&r2=604971&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java Mon Dec 17 11:05:41 2007
@@ -37,6 +37,7 @@
//Mode 2 (ImageEncoder)
private ImageEncoder encoder;
private ColorSpace colorSpace;
+ private int bitsPerComponent = 8;
private boolean invertImage;
private Dimension pixelDimensions;
@@ -67,16 +68,36 @@
* @param dimensionsPx the form's dimensions in pixels
* @param encoder the image encoder
* @param colorSpace the target color space
+ * @param bitsPerComponent the bits per component
* @param invertImage true if the image shall be inverted
*/
public ImageFormGenerator(String formName, String title,
Dimension2D dimensions, Dimension dimensionsPx,
- ImageEncoder encoder, ColorSpace colorSpace, boolean invertImage) {
+ ImageEncoder encoder,
+ ColorSpace colorSpace, int bitsPerComponent, boolean invertImage) {
super(formName, title, dimensions);
+ this.pixelDimensions = dimensionsPx;
this.encoder = encoder;
this.colorSpace = colorSpace;
+ this.bitsPerComponent = bitsPerComponent;
this.invertImage = invertImage;
- this.pixelDimensions = dimensionsPx;
+ }
+
+ /**
+ * Main constructor.
+ * @param formName the form's name
+ * @param title the form's title or null
+ * @param dimensions the form's dimensions in units (usually points)
+ * @param dimensionsPx the form's dimensions in pixels
+ * @param encoder the image encoder
+ * @param colorSpace the target color space
+ * @param invertImage true if the image shall be inverted
+ */
+ public ImageFormGenerator(String formName, String title,
+ Dimension2D dimensions, Dimension dimensionsPx,
+ ImageEncoder encoder,
+ ColorSpace colorSpace, boolean invertImage) {
+ this(formName, title, dimensions, dimensionsPx, encoder, colorSpace, 8, invertImage);
}
/**
@@ -121,13 +142,13 @@
if (this.image != null) {
PSImageUtils.writeImageCommand(this.image, imageDict, gen);
} else {
- imageDict.put("/BitsPerComponent", Integer.toString(8));
+ imageDict.put("/BitsPerComponent", Integer.toString(this.bitsPerComponent));
PSImageUtils.writeImageCommand(imageDict,
this.pixelDimensions, this.colorSpace, this.invertImage,
gen);
}
}
-
+
/** {@inheritDoc} */
protected void generateAdditionalDataStream(PSGenerator gen) throws IOException {
gen.writeln("/" + getDataName() + " currentfile");
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java?rev=604971&r1=604970&r2=604971&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSImageUtils.java Mon Dec 17 11:05:41 2007
@@ -74,7 +74,7 @@
}
}
};
- writeImage(encoder, imgDim, imgDescription, targetRect, colorSpace, false, gen);
+ writeImage(encoder, imgDim, imgDescription, targetRect, colorSpace, 8, false, gen);
}
/**
@@ -84,6 +84,7 @@
* @param imgDescription the name of the image
* @param targetRect the target rectangle to place the image in
* @param colorSpace the color space of the image
+ * @param bitsPerComponent the number of bits per component
* @param invertImage true if the image shall be inverted
* @param gen the PostScript generator
* @throws IOException In case of an I/O exception
@@ -91,7 +92,7 @@
public static void writeImage(ImageEncoder encoder,
Dimension imgDim, String imgDescription,
Rectangle2D targetRect,
- ColorSpace colorSpace, boolean invertImage,
+ ColorSpace colorSpace, int bitsPerComponent, boolean invertImage,
PSGenerator gen) throws IOException {
gen.saveGraphicsState();
translateAndScale(gen, null, targetRect);
@@ -117,7 +118,7 @@
}
PSDictionary imageDict = new PSDictionary();
imageDict.put("/DataSource", "Data");
- imageDict.put("/BitsPerComponent", Integer.toString(8));
+ imageDict.put("/BitsPerComponent", Integer.toString(bitsPerComponent));
writeImageCommand(imageDict, imgDim, colorSpace, invertImage, gen);
/* the following two lines could be enabled if something still goes wrong
* gen.write("Data closefile");
---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org