Skip to content

Commit

Permalink
Deltavision: flip images right-side-up
Browse files Browse the repository at this point in the history
Closes #9186.

Apparently, we have been reading all Deltavision images incorrectly for
the last 6.5 years.
  • Loading branch information
melissalinkert committed Jul 25, 2012
1 parent d47f4af commit 9d60865
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,18 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
long offset = planeOffset + HEADER_LENGTH + extSize;
if (offset < in.length()) {
in.seek(HEADER_LENGTH + extSize + planeOffset);
readPlane(in, x, y, w, h, buf);
readPlane(in, x, getSizeY() - h - y, w, h, buf);

// reverse the order of the rows
// planes are stored with the origin in the lower-left corner
byte[] tmp = new byte[w * FormatTools.getBytesPerPixel(getPixelType())];
for (int row=0; row<h/2; row++) {
int src = row * tmp.length;
int dest = (h - row - 1) * tmp.length;
System.arraycopy(buf, src, tmp, 0, tmp.length);
System.arraycopy(buf, dest, buf, src, tmp.length);
System.arraycopy(tmp, 0, buf, dest, tmp.length);
}
}

return buf;
Expand Down

0 comments on commit 9d60865

Please sign in to comment.