[FOray-commit] SF.net SVN: foray: [8627] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-02-09 18:11:08
|
Revision: 8627
http://svn.sourceforge.net/foray/?rev=8627&view=rev
Author: victormote
Date: 2007-02-09 10:11:08 -0800 (Fri, 09 Feb 2007)
Log Message:
-----------
1. Convert TIFF logic to return the raw content instead of the uncompressed content.
2. Adjust test accordingly.
3. Tests now pass.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestJpegGraphic.java
trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestTiffGraphic.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXImage.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java 2007-02-09 17:52:41 UTC (rev 8626)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java 2007-02-09 18:11:08 UTC (rev 8627)
@@ -75,6 +75,9 @@
/** The compression for this graphic. */
private int compression = Graphic.COMPRESSION_UNKNOWN;
+ /** Raw image samples (possibly compressed). */
+ private byte[] rawContent = null;
+
/**
* Constructor.
* @param server The parent graphic server.
@@ -167,7 +170,7 @@
+ "length mismatch on read");
}
- setContent(readBuf);
+ this.rawContent = readBuf;
} catch (final GraphicException fie) {
getLogger().error("Reverting to TIFF image handling "
+ "through JAI: " + fie.getMessage());
@@ -213,8 +216,16 @@
* {@inheritDoc}
*/
public byte[] getRawSamples() throws GraphicException {
+ this.loadImageWrapper();
+ return this.rawContent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getContent() throws GraphicException {
/* TODO: Add support for this feature. */
- throw new GraphicException("Unsupported feature getRawSamples() in "
+ throw new GraphicException("Unsupported feature getContent() in "
+ this.getClass().getName() + "for: "
+ this.getUrl().toExternalForm());
}
Modified: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestJpegGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestJpegGraphic.java 2007-02-09 17:52:41 UTC (rev 8626)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestJpegGraphic.java 2007-02-09 18:11:08 UTC (rev 8627)
@@ -60,7 +60,7 @@
/* JPEG doesn't currently support returning the standard getContent(),
* but returns its (compressed) data instead.
* The following computations are for uncompressed data, and are for
- * rfeference purposes only:
+ * reference purposes only:
* 216 pixel width * 144 pixel height = 31,104 pixels.
* 31,104 pixels * 3 channels * 8 bits per channel = 746,496 bits.
* 746,496 / 8 bits per byte = 93,312 bytes. */
Modified: trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestTiffGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestTiffGraphic.java 2007-02-09 17:52:41 UTC (rev 8626)
+++ trunk/foray/foray-graphic/src/javatest/org/foray/graphic/TestTiffGraphic.java 2007-02-09 18:11:08 UTC (rev 8627)
@@ -54,12 +54,17 @@
assertTrue(tiff.getColorSpace().getType() == ColorSpace.TYPE_GRAY);
assertFalse(tiff.isTransparent());
assertNull(tiff.getTransparentColor());
- final byte[] content = tiff.getContent();
+ final byte[] content = tiff.getRawSamples();
assertNotNull(content);
- /* 700 pixel width * 81 pixel height = 56,700 pixels.
+
+ /* TIFF doesn't currently support returning the standard getContent(),
+ * but returns its (compressed) data instead.
+ * The following computations are for uncompressed data, and are for
+ * reference purposes only:
+ * 700 pixel width * 81 pixel height = 56,700 pixels.
* 56,700 pixels * 1 channels * 1 bits per channel = 56,700 bits.
* 56,700 / 8 bits per byte = 7,088 bytes. */
- assertEquals(7088, content.length);
+ assertEquals(1526, content.length);
}
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXImage.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXImage.java 2007-02-09 17:52:41 UTC (rev 8626)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFXImage.java 2007-02-09 18:11:08 UTC (rev 8627)
@@ -78,7 +78,15 @@
protected void xObjectContent(final PDFStream stream)
throws GraphicException, IOException {
- stream.setData(getGraphic().getContent());
+ if (getGraphic().getGraphicType() == Graphic.TYPE_JPEG
+ || getGraphic().getGraphicType() == Graphic.TYPE_TIFF) {
+ /* JPEG is natively compressed using DTD, so use its raw content.
+ * TIFF is currently presumed to be compressed natively also, and
+ * an appropriate filter has been added for that compression. */
+ stream.setData(getGraphic().getRawSamples());
+ } else {
+ stream.setData(getGraphic().getContent());
+ }
}
protected String xObjectDictionary() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|