From e4eabd3511df21f9963ba15d9f7819a4b2afc78e Mon Sep 17 00:00:00 2001 From: jenche Date: Mon, 16 Apr 2012 21:08:56 +0200 Subject: [PATCH] Fox for issue #322 "Cineon reading bug" --- src/cineon.imageio/libcineon/ReaderInternal.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cineon.imageio/libcineon/ReaderInternal.h b/src/cineon.imageio/libcineon/ReaderInternal.h index 42e141cb7f..0c77b6e9a9 100644 --- a/src/cineon.imageio/libcineon/ReaderInternal.h +++ b/src/cineon.imageio/libcineon/ReaderInternal.h @@ -72,14 +72,20 @@ namespace cineon // end of line padding int eolnPad = dpxHeader.EndOfLinePadding(); + // number of datums in one row + int datums = dpxHeader.Width() * numberOfComponents; + + // Line length in bytes rounded to 32 bits boundary + int lineLength = ((datums - 1) / 3 + 1) * 4; // read in each line at a time directly into the user memory space for (int line = 0; line < height; line++) { + // determine offset into image element + int actline = line + block.y1; + // first get line offset - long offset = (line + block.y1) * dpxHeader.Width() * numberOfComponents; - offset += offset % 3; - offset = offset / 3 * 4; + long offset = actline * lineLength; // add in eoln padding offset += line * eolnPad;