Skip to content

Commit

Permalink
Fix 4-pixel correction for 0x1000000
Browse files Browse the repository at this point in the history
  • Loading branch information
zacsimile committed Dec 6, 2024
1 parent 8a7196e commit 733c051
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions components/formats-gpl/src/loci/formats/in/DCIMGReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import loci.formats.FormatTools;
import loci.formats.MetadataTools;
import loci.formats.meta.MetadataStore;
import ucar.nc2.util.IO;

/**
* DCIMGReader reads Hamamatsu DCIMG files.
Expand Down Expand Up @@ -372,19 +373,28 @@ private void parseDCAMVersion0Footer(RandomAccessInputStream stream)

// Get the correct line and offset for the 4 pixel correction
private int getFourPixelCorrectionLine()
throws IOException
{
if (version == DCIMG_VERSION_0) {
if (fourPixelCorrectionInFooter) {
return ((int)(fourPixelOffsetInFrame / bytesPerRow + 1)); // TODO: Why do we need the +1?
} else {
return (getSizeX() - 1);
return (getSizeY() - 1);
}
}
if (version == DCIMG_VERSION_1) {
if (frameFooterSize >= 512) {
if ((frameFooterSize >= 512) | (frameFooterSize == 32)){
fourPixelCorrectionInFooter = true;
}
return (getSizeY() / 2); // TODO: is this legal?

// TODO: This is a guess because the spec in
// https://github.com/lens-biophotonics/dcimg/blob/master/dcimg.py
// resulted in a div by zero on my example file.
if ((getSizeY() % 2) == 0) {
return (getSizeY() / 2);
} else {
return (getSizeY() / 2 + 1);
}
}
return 0;
}
Expand Down

0 comments on commit 733c051

Please sign in to comment.