Login  Register

Bug with Virtual Stacks for large (>2^31) offsets

Posted by Josh Doe-2 on Apr 02, 2009; 7:48pm
URL: http://imagej.273.s1.nabble.com/Bug-with-Virtual-Stacks-for-large-2-31-offsets-tp3693116.html

I've been trying to read in a 15GB RAW file as a Virtual Stack, and
everything was working fine until I tried to have an offset greater
than 2^31-1, or 2147483647. The resulting Virtual Stack would start at
the beginning of the file instead of 2GB in. I looked in the source
code and found the problem in plugin/FileInfoVirtualStack.java. That
file fails to use longOffset when needed, instead always using offset,
which is an integer (and thus the 2^31-1 problem). There are various
ways to fix it, but here's the one that worked for me (in open()):
if(fi.longOffset>0)
  info[i].longOffset = fi.longOffset + i*(size + fi.gapBetweenImages);
else
  info[i].longOffset = (long)fi.offset + i*(size + fi.gapBetweenImages);

Honestly I'm not sure why there are two different offsets and not just
one offset that's long, but it doesn't matter.

Thanks!
-Josh