Re: Fix for: ImageJ cannot open 48-bit LZW compressed TIFFs
Posted by Olaf Freyer-3 on Jul 19, 2009; 11:48am
URL: http://imagej.273.s1.nabble.com/Re-Fix-for-ImageJ-cannot-open-48-bit-LZW-compressed-TIFFs-tp3691731.html
Thanks alot for including my proposed patch.
During further testing of the code I came across some other 48-bit LZW
compresses TIFFs that cause an IndexOutOfBoundsException with the current
code. It seems like sometimes the decompresses data contained a few bytes
too much.
The simple fix for this issue is:
--- source/ij/io/ImageReader.java 2009-07-19 13:45:10.000000000 +0200
+++ source_fixed/ij/io/ImageReader.java 2009-07-19 13:46:14.000000000 +0200
@@ -558,7 +558,7 @@
int value;
int channel=0;
boolean intel = fi.intelByteOrder;
- for (int base=0; base<len; base+=2) {
+ for (int base=0; base<len && pixel<nPixels; base+=2) {
if (intel)
value = ((buffer[base+1]&0xff)<<8) |
(buffer[base]&0xff);
else
Regards
Olaf Freyer