On 13-04-17 01:17 PM, Chip Collier wrote:
Thanks Halfdan,
I've tried it both ways but get the same results.
Attached is the modifications I made to swap the x/y coordinates. Works
fine for me after the changes.
Tested on 64-bit Linux.
Loads in Nuke, even :-)
- ½
#include <ImfDeepScanLineOutputFile.h>
#include <ImfDeepFrameBuffer.h>
#include <ImfChannelList.h>
#include <ImfArray.h>
#include <ImfPixelType.h>
#include <ImfPartType.h>
#include <ImfLineOrder.h>
#include <ImfCompression.h>
#include <ImfCompressionAttribute.h>
#include <ImfLineOrderAttribute.h>
#include <ImfMatrixAttribute.h>
#include <ImathVec.h>
#include <ImathBox.h>
#include <half.h>
static int xRes=32, yRes=32;
int main(int argc, char **argv)
{
Imf::Header exrHeader(xRes, yRes);
exrHeader.setType(Imf::DEEPSCANLINE);
exrHeader.insert("compression", Imf::CompressionAttribute(Imf::NO_COMPRESSION));
Imf::DeepFrameBuffer exrFrameBuffer;
Imf::Array2D<unsigned int> sampleCount;
sampleCount.resizeErase(yRes, xRes);
Imf::Array2D<float*> zdata;
zdata.resizeErase(yRes, xRes);
Imf::Array2D<half*> odata;
odata.resizeErase(yRes, xRes);
exrFrameBuffer.insertSampleCountSlice(
Imf::Slice(Imf::UINT,
(char*)(&sampleCount[0][0]),
sizeof(unsigned int),
sizeof(unsigned int) * xRes)
);
exrHeader.channels().insert("Z", Imf::Channel(Imf::FLOAT));
exrHeader.channels().insert("O", Imf::Channel(Imf::HALF));
Imf::DeepScanLineOutputFile exrFile(argv[1], exrHeader);
exrFrameBuffer.insert(
"Z",
Imf::DeepSlice(Imf::FLOAT,
(char*)(&zdata[0][0]),
sizeof(float*),
sizeof(float*) * xRes,
sizeof(float))
);
exrFrameBuffer.insert(
"O",
Imf::DeepSlice(Imf::HALF,
(char*)(&odata[0][0]),
sizeof(half*),
sizeof(half*) * xRes,
sizeof(half))
);
exrFile.setFrameBuffer(exrFrameBuffer);
int sampleSize = 2;
for (int y=0; y < yRes; y++) {
for (int x=0; x < xRes; x++) {
sampleCount[y][x] = sampleSize;
zdata[y][x] = new float[sampleSize];
odata[y][x] = new half[sampleSize];
zdata[y][x][0] = -1.0f + ((x / xRes)*2.0f);
zdata[y][x][1] = 2.0f - ((y / yRes)*2.0f);
odata[y][x][0] = 0.5f;
odata[y][x][1] = 1.0f;
}
exrFile.writePixels(1);
}
for (int y=0; y < yRes; y++) {
for (int x=0; x < xRes; x++) {
delete [] zdata[y][x];
}
}
return 0;
}
_______________________________________________
Openexr-devel mailing list
Openexr-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/openexr-devel