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;
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;
if (l > 0) {
info.dpiVertical = l / 39.37d;
}
-
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
&& (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;
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;
byte1 = header[8] & 0xff;
byte2 = header[9] & 0xff;
info.height = ((byte2 << 8) | byte1) & 0xffff;
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
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;
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);
info.dpiHorizontal = xdensity;
info.dpiVertical = ydensity;
} else {
- //nop, nyi --> 72dpi
+ // Use resolution specified in
+ // FOUserAgent.getFactory() (default 72dpi).
}
int restlen = reclen - 12;
}
throw ioe;
}
- return info;
}
private int read2bytes(InputStream imageStream) throws IOException {
&& (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;
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;
byte4 = header[23] & 0xff;
l = (long) ((byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4);
info.height = (int) l;
- return info;
}
private byte[] getDefaultHeader(InputStream imageStream)
}
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;
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)
<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.