Hi Richard,
It may also be instructive to confirm the library built correctly by
building and running the IlmImfTest suite. Running IlmImfTest with
"deep" as an argument will run only the deep tests.
The source code of those tests should provide further examples of how to
read/write deep data. The different tests intentionally use slightly
different approaches to read/write data. You might modify one of those
tests to disable the file cleanup, which would generate a deep file you
can read with your own code, and compare to the known values written
into the file.
Are you getting the correct sample counts but entirely incorrect data?
That would suggest you have the pointer-to-arrays pointing to the wrong
memory locations. If some of the values are correct (e.g. only the first
pixel in the image, only the first pixel on each row, or only the first
sample of each pixel) that would suggest the pointers are correct, but
the yPixelStride,xPixelStride,sampleStride (respectively) values are wrong.
Try writing a small amount of 32 bit float data (e.g. a 2x2 pixel image
with 1 channel) with compression set to NO_COMPRESSION and check the
file contents in a hex editor: the last 4 bytes of the file should be
the last sample of the last pixel of the last channel in the file. That
might tell you whether you are writing the file correctly.
Re: [Openexr-devel] Problem with deep data
Hallo Richard,
This is a snippet from my simple deep reader (half RGBA, float Z)-
minus all the cleanup.
It was written some time ago as a simple test, but it works for the
purpose. Maybe it helps you find the issue.
--- snip ---
Imf::Array2D< unsigned int > sampleCount;
Imf::Array2D< half* > dataR, dataG, dataB, dataA;
void readDeepExr(const char *filename)
{
 Imf::DeepScanLineInputFile file(filename);
 const Imf::Header &header = file.header();
 dataWindow = header.dataWindow();
 displayWindow = header.displayWindow();
 width = dataWindow.max.x - dataWindow.min.x + 1;
 height = dataWindow.max.y - dataWindow.min.y + 1;
 sampleCount.resizeEraseUnsafe(height, width);
 Imf::Array2D< float* >dataZ(height, width);
 dataR.resizeEraseUnsafe(height, width);
dataG.resizeEraseUnsafe(height, width);
 dataB.resizeEraseUnsafe(height, width);
dataA.resizeEraseUnsafe(height, width);
 Imf::DeepFrameBuffer frameBuffer;
 frameBuffer.insertSampleCountSlice (Imf::Slice (Imf::UINT,
  (char *) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y
* width),
  sizeof (unsigned int) * 1, // xStride
  sizeof (unsigned int) * width)); // yStride
 frameBuffer.insert ("Z",
  Imf::DeepSlice (Imf::FLOAT, (char *) (&dataZ[0][0] -
dataWindow.min.x - dataWindow.min.y * width),
  sizeof (float *) * 1, // xStride for pointer array
  sizeof (float *) * width, // yStride for pointer array
  sizeof (float) * 1)); // stride for Z data sample
 frameBuffer.insert ("R",
  Imf::DeepSlice (Imf::HALF, (char *) (&dataR[0][0] -
dataWindow.min.x - dataWindow.min.y * width),
  sizeof (half *), // xStride for pointer array
  sizeof (half *) * width, // yStride for pointer array
  sizeof (half))); // stride for O data sample
 frameBuffer.insert ("G",
  Imf::DeepSlice (Imf::HALF, (char *) (&dataG[0][0] -
dataWindow.min.x - dataWindow.min.y * width),
  sizeof (half *), sizeof (half *) * width, sizeof (half)));
 frameBuffer.insert ("B",
  Imf::DeepSlice (Imf::HALF, (char *) (&dataB[0][0] -
dataWindow.min.x - dataWindow.min.y * width),
  sizeof (half *), sizeof (half *) * width, sizeof (half)));
 frameBuffer.insert ("A",
  Imf::DeepSlice (Imf::HALF, (char *) (&dataA[0][0] -
dataWindow.min.x - dataWindow.min.y * width),
  sizeof (half *), sizeof (half *) * width, sizeof (half)));
 file.setFrameBuffer(frameBuffer);
 file.readPixelSampleCounts(dataWindow.min.y, dataWindow.max.y);
 for (int y = 0; y < height; y++)
 {
  for (int x = 0; x < width; x++)
  {
   int s = sampleCount[y][x];
   dataZ[y][x] = new float[s];
   dataR[y][x] = new half[s];
   dataG[y][x] = new half[s];
   dataB[y][x] = new half[s];
   dataA[y][x] = new half[s];
  }
 }
 file.readPixels(dataWindow.min.y, dataWindow.max.y);
 std::cout << "Done.\n";
 // clean up etc...
}
--- snip ---
Cheers,
Mike
/--
db&w Bornemann und Wolf GbR
Seyfferstr. 34
70197 Stuttgart
Deutschland
/
/http://www.db-w.com
/
tel: +49 (711) 664 525-3
fax: +49 (711) 664 525-1
mob: +49 (173) 66 37 652
skype: lupus_lux
_______________________________________________
Openexr-devel mailing list
https://lists.nongnu.org/mailman/listinfo/openexr-devel