Re: Fix for: ImageJ cannot open 48-bit LZW compressed TIFFs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Fix for: ImageJ cannot open 48-bit LZW compressed TIFFs

Olaf Freyer-3
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