Here's a fix for nFop that corrects the corruption of large
Gif and Bmp images. I have altered the FlateFilter.java
class that is peforming the zip compression on the
images.
I'm using the SharpZipLib
(http://www.icsharpcode.net/OpenSource/SharpZipLib/)
libraries in place of the J# compression code that is
often quoted as having issues with large files.
Add a reference to ICSharpCode.SharpZipLib
Add these imports to FlateFilter.java
import System.IO.MemoryStream;
import
ICSharpCode.SharpZipLib.Zip.Compression.Streams.Defl
aterOutputStream;
import ICSharpCode.SharpZipLib.Zip.ZipException;
and replace the encode method with this.
public byte[] encode(byte[] data) {
// need to convert the byte[] into a
ubyte[] for SharpZipLib
ubyte [] udata = new ubyte
[data.length];
System.Buffer.BlockCopy(data,
0, udata, 0, data.length);
MemoryStream outArrayStream =
new MemoryStream();
_predictor = PREDICTION_NONE;
try
{
DeflaterOutputStream
compressedStream =
new
DeflaterOutputStream(outArrayStream);
compressedStream.Write(udata, 0,
udata.length);
compressedStream.Flush();
compressedStream.Close();
}
catch (ZipException e)
{
org.apache.fop.messaging.MessageHandler.e
rror("Fatal error: "
+ e.ToString
());
}
udata = outArrayStream.ToArray();
// convert ubyte[] back to byte[]
byte [] out = new byte
[udata.length];
System.Buffer.BlockCopy(udata,
0, out, 0, udata.length);
return out;
}
FlateFilter.java