You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/05/21 09:59:10 UTC
svn commit: r540052 - in /xmlgraphics/fop/trunk: ./
src/java/org/apache/fop/image/analyser/
Author: jeremias
Date: Mon May 21 00:59:05 2007
New Revision: 540052
URL: http://svn.apache.org/viewvc?view=rev&rev=540052
Log:
Bugzilla #42406:
Use source resolution setting for bitmap images which don't provide their own resolution.
Submitted by: Hussein Shafie <hussein.at.xmlmind.com>
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/BMPReader.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/GIFReader.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/JPEGReader.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/PNGReader.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/TIFFReader.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/BMPReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/BMPReader.java?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/BMPReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/BMPReader.java Mon May 21 00:59:05 2007
@@ -54,7 +54,11 @@
boolean supported = ((header[0] == (byte) 0x42)
&& (header[1] == (byte) 0x4d));
if (supported) {
- FopImage.ImageInfo info = getDimension(header);
+ FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.dpiHorizontal = ua.getFactory().getSourceResolution();
+ info.dpiVertical = info.dpiHorizontal;
+
+ getDimension(header, info);
info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
@@ -73,9 +77,7 @@
return "image/bmp";
}
- private FopImage.ImageInfo getDimension(byte[] header) {
- FopImage.ImageInfo info = new FopImage.ImageInfo();
-
+ private void getDimension(byte[] header, FopImage.ImageInfo info) {
// little endian notation
int byte1 = header[WIDTH_OFFSET] & 0xff;
int byte2 = header[WIDTH_OFFSET + 1] & 0xff;
@@ -109,8 +111,6 @@
if (l > 0) {
info.dpiVertical = l / 39.37d;
}
-
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/GIFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/GIFReader.java?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/GIFReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/GIFReader.java Mon May 21 00:59:05 2007
@@ -48,7 +48,11 @@
&& (header[4] == '7' || header[4] == '9')
&& (header[5] == 'a'));
if (supported) {
- FopImage.ImageInfo info = getDimension(header);
+ FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.dpiHorizontal = ua.getFactory().getSourceResolution();
+ info.dpiVertical = info.dpiHorizontal;
+
+ getDimension(header, info);
info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
@@ -67,8 +71,7 @@
return "image/gif";
}
- private FopImage.ImageInfo getDimension(byte[] header) {
- FopImage.ImageInfo info = new FopImage.ImageInfo();
+ private void getDimension(byte[] header, FopImage.ImageInfo info) {
// little endian notation
int byte1 = header[6] & 0xff;
int byte2 = header[7] & 0xff;
@@ -77,7 +80,6 @@
byte1 = header[8] & 0xff;
byte2 = header[9] & 0xff;
info.height = ((byte2 << 8) | byte1) & 0xffff;
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/JPEGReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/JPEGReader.java?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/JPEGReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/JPEGReader.java Mon May 21 00:59:05 2007
@@ -61,7 +61,11 @@
boolean supported = ((header[0] == (byte) 0xff)
&& (header[1] == (byte) 0xd8));
if (supported) {
- FopImage.ImageInfo info = getDimension(fis);
+ FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.dpiHorizontal = ua.getFactory().getSourceResolution();
+ info.dpiVertical = info.dpiHorizontal;
+
+ getDimension(fis, info);
info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = fis;
@@ -97,8 +101,9 @@
return header;
}
- private FopImage.ImageInfo getDimension(InputStream imageStream) throws IOException {
- FopImage.ImageInfo info = new FopImage.ImageInfo();
+ private void getDimension(InputStream imageStream,
+ FopImage.ImageInfo info)
+ throws IOException {
try {
int pos=0, avail = imageStream.available();
imageStream.mark(avail);
@@ -163,7 +168,8 @@
info.dpiHorizontal = xdensity;
info.dpiVertical = ydensity;
} else {
- //nop, nyi --> 72dpi
+ // Use resolution specified in
+ // FOUserAgent.getFactory() (default 72dpi).
}
int restlen = reclen - 12;
@@ -237,7 +243,6 @@
}
throw ioe;
}
- return info;
}
private int read2bytes(InputStream imageStream) throws IOException {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/PNGReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/PNGReader.java?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/PNGReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/PNGReader.java Mon May 21 00:59:05 2007
@@ -51,7 +51,11 @@
&& (header[7] == (byte) 0x0a));
if (supported) {
- FopImage.ImageInfo info = getDimension(header);
+ FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.dpiHorizontal = ua.getFactory().getSourceResolution();
+ info.dpiVertical = info.dpiHorizontal;
+
+ getDimension(header, info);
info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
@@ -70,9 +74,7 @@
return "image/png";
}
- private FopImage.ImageInfo getDimension(byte[] header) {
- FopImage.ImageInfo info = new FopImage.ImageInfo();
-
+ private void getDimension(byte[] header, FopImage.ImageInfo info) {
// png is always big endian
int byte1 = header[16] & 0xff;
int byte2 = header[17] & 0xff;
@@ -90,7 +92,6 @@
byte4 = header[23] & 0xff;
l = (long) ((byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4);
info.height = (int) l;
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/TIFFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/TIFFReader.java?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/TIFFReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/TIFFReader.java Mon May 21 00:59:05 2007
@@ -62,7 +62,11 @@
}
if (supported) {
- FopImage.ImageInfo info = getDimension(header);
+ FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.dpiHorizontal = ua.getFactory().getSourceResolution();
+ info.dpiVertical = info.dpiHorizontal;
+
+ getDimension(header, info);
info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
@@ -81,33 +85,14 @@
return "image/tiff";
}
- private FopImage.ImageInfo getDimension(byte[] header) {
+ private void getDimension(byte[] header, FopImage.ImageInfo info) {
// currently not setting the width and height
// these are set again by the Jimi image reader.
// I suppose I'll do it one day to be complete. Or
// someone else will.
// Note: bytes 4,5,6,7 contain the byte offset in the stream of the first IFD block
- /*
- * //png is always big endian
- * int byte1 = header[ 16 ] & 0xff;
- * int byte2 = header[ 17 ] & 0xff;
- * int byte3 = header[ 18 ] & 0xff;
- * int byte4 = header[ 19 ] & 0xff;
- * long l = ( long ) ( ( byte1 << 24 ) | ( byte2 << 16 ) |
- * ( byte3 << 8 ) | byte4 );
- * this.width = ( int ) ( l );
- * byte1 = header[ 20 ] & 0xff;
- * byte2 = header[ 21 ] & 0xff;
- * byte3 = header[ 22 ] & 0xff;
- * byte4 = header[ 23 ] & 0xff;
- * l = ( long ) ( ( byte1 << 24 ) | ( byte2 << 16 ) | ( byte3 << 8 ) |
- * byte4 );
- * this.height = ( int ) ( l );
- */
- FopImage.ImageInfo info = new FopImage.ImageInfo();
info.width = -1;
info.height = -1;
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?view=diff&rev=540052&r1=540051&r2=540052
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Mon May 21 00:59:05 2007
@@ -28,6 +28,10 @@
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="JM" type="update" fixes-bug="42406" due-to="Hussein Shafie">
+ Use source resolution setting for bitmap images which don't provide their own
+ resolution.
+ </action>
<action context="Code" dev="JM" type="fix" fixes-bug="42109" due-to="Paul Vinkenoog">
Fixed the rendering of zero-width spaces for certain fonts by not generating them into
the area tree.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org