openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] Problem with deep data


From: Michael Wolf
Subject: Re: [Openexr-devel] Problem with deep data
Date: Thu, 19 Apr 2018 23:45:27 +0200

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
 
address@hidden
 
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
msn:  
address@hidden
reply via email to

[Prev in Thread] Current Thread [Next in Thread]