Bläddra i källkod

Bugzilla #40062:

Fixed handling for CCITT Group 4 images with fill order 2.
Submitted by: Gilles Beaugeais <gbeaugeais.at.voila.fr>

JM: Patch slightly modified/streamlined.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@424979 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_93
Jeremias Maerki 18 år sedan
förälder
incheckning
0fdd652c38
2 ändrade filer med 58 tillägg och 1 borttagningar
  1. 52
    1
      src/java/org/apache/fop/image/TIFFImage.java
  2. 6
    0
      status.xml

+ 52
- 1
src/java/org/apache/fop/image/TIFFImage.java Visa fil

@@ -37,7 +37,8 @@ public class TIFFImage extends XmlGraphicsCommonsImage {
private int stripCount = 0;
private long stripOffset = 0;
private long stripLength = 0;
private int fillOrder = 1;

/**
* Constructs a new BatikImage instance.
* @param imgReader basic metadata for the image
@@ -106,6 +107,12 @@ public class TIFFImage extends XmlGraphicsCommonsImage {
stripCount = (int)(dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH)
/ fld.getAsLong(0));
}

fld = dir.getField(TIFFImageDecoder.TIFF_FILL_ORDER);
if (fld != null) {
fillOrder = fld.getAsInt(0);
}

stripOffset = dir.getField(TIFFImageDecoder.TIFF_STRIP_OFFSETS).getAsLong(0);
stripLength = dir.getField(TIFFImageDecoder.TIFF_STRIP_BYTE_COUNTS).getAsLong(0);
@@ -136,7 +143,14 @@ public class TIFFImage extends XmlGraphicsCommonsImage {
return false;
}

// need to invert bytes if fill order = 2
if (fillOrder == 2) {
for (int i = 0; i < (int)stripLength; i++) {
readBuf[i] = flipTable[readBuf[i] & 0xff];
}
}
this.raw = readBuf;

return true;
} catch (IOException ioe) {
log.error("Error while loading image strip 1 (TIFF): ", ioe);
@@ -152,4 +166,41 @@ public class TIFFImage extends XmlGraphicsCommonsImage {
return false;
}

// Table to be used when fillOrder = 2, for flipping bytes.
// Copied from XML Graphics Commons' TIFFFaxDecoder class
private static byte[] flipTable = {
0, -128, 64, -64, 32, -96, 96, -32,
16, -112, 80, -48, 48, -80, 112, -16,
8, -120, 72, -56, 40, -88, 104, -24,
24, -104, 88, -40, 56, -72, 120, -8,
4, -124, 68, -60, 36, -92, 100, -28,
20, -108, 84, -44, 52, -76, 116, -12,
12, -116, 76, -52, 44, -84, 108, -20,
28, -100, 92, -36, 60, -68, 124, -4,
2, -126, 66, -62, 34, -94, 98, -30,
18, -110, 82, -46, 50, -78, 114, -14,
10, -118, 74, -54, 42, -86, 106, -22,
26, -102, 90, -38, 58, -70, 122, -6,
6, -122, 70, -58, 38, -90, 102, -26,
22, -106, 86, -42, 54, -74, 118, -10,
14, -114, 78, -50, 46, -82, 110, -18,
30, -98, 94, -34, 62, -66, 126, -2,
1, -127, 65, -63, 33, -95, 97, -31,
17, -111, 81, -47, 49, -79, 113, -15,
9, -119, 73, -55, 41, -87, 105, -23,
25, -103, 89, -39, 57, -71, 121, -7,
5, -123, 69, -59, 37, -91, 101, -27,
21, -107, 85, -43, 53, -75, 117, -11,
13, -115, 77, -51, 45, -83, 109, -19,
29, -99, 93, -35, 61, -67, 125, -3,
3, -125, 67, -61, 35, -93, 99, -29,
19, -109, 83, -45, 51, -77, 115, -13,
11, -117, 75, -53, 43, -85, 107, -21,
27, -101, 91, -37, 59, -69, 123, -5,
7, -121, 71, -57, 39, -89, 103, -25,
23, -105, 87, -41, 55, -73, 119, -9,
15, -113, 79, -49, 47, -81, 111, -17,
31, -97, 95, -33, 63, -65, 127, -1,
};
// end
}

+ 6
- 0
status.xml Visa fil

@@ -27,6 +27,12 @@

<changes>
<release version="FOP Trunk">
<action context="Code" dev="JM" type="fix" fixes-bug="40062" due-to="Gilles Beaugeais">
Fixed handling for CCITT Group 4 TIFF images with fill order 2.
</action>
<action context="Code" dev="JM" type="fix" fixes-bug="40048" due-to="Igor Istomin">
Fixed setting of page margins in AWT Renderer like it was done in the print renderer.
</action>
<action context="Code" dev="JM" type="fix">
Fixed two memory-leaks in image handling. The image cache is finally working
properly.

Laddar…
Avbryt
Spara