[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Openexr-devel] How can I modify the function of openexr
From: |
Yan |
Subject: |
[Openexr-devel] How can I modify the function of openexr |
Date: |
Thu, 27 Nov 2014 14:53:26 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
dear all,
As title, I want to modify the function of openexr.
I try to modify the source code of ImfPizCompressor.cpp, only add one
line: printf("start wavelet encoding\n");, and then build the openexr
library.
But after I build the openexr library and write an test code, the
sentence that I expect to output is not output.
So, whether the result means that I don't modify the function
successfully?
And, how can I modify the function of openexr?
The test codes I use are below:
#include <iostream>
#include <tchar.h>
#include <string.h>
#include <fstream>
#include <math.h>
#define OPENEXR_DLL
#include <ImfOutputFile.h>
#include <ImfInputFile.h>
#include <ImfChannelList.h>
#include <ImfArray.h>
#include <Iex.h>
#include <half.h>
#include <ImfNamespace.h>
#include "ImfHeader.h"
using namespace std;
using namespace Imf;
using namespace Imath;
int _tmain(int argc, _TCHAR* argv[])
{
int width = 0;
int height = 0;
Array2D<half> rUncompressionPixels;
Array2D<half> gUncompressionPixels;
Array2D<half> bUncompressionPixels;
printf("\nOpenEXR Test Piz Compression\n");
InputFile fileUncompression
("OpenEXR_uncompression_1x6_red.exr");
//InputFile file ("OpenEXR_piz_1x6_red.exr");
Box2i dw = fileUncompression.header().dataWindow();
width = dw.max.x - dw.min.x + 1;
height = dw.max.y - dw.min.y + 1;
rUncompressionPixels.resizeErase (height, width);
gUncompressionPixels.resizeErase (height, width);
bUncompressionPixels.resizeErase (height, width);
FrameBuffer frameBuffer;
frameBuffer.insert ("R",
// name
Slice (HALF,
// type
(char *)
(&rUncompressionPixels[0][0] - dw.min.x - dw.min.y * width),
// base
sizeof
(rUncompressionPixels[0][0]) * 1,
// xStride
sizeof
(rUncompressionPixels[0][0]) * width,
// yStride
1, 1,
// fillValue
0.0));
frameBuffer.insert ("G",
Slice (HALF,
(char *)
(&gUncompressionPixels[0][0] - dw.min.x - dw.min.y * width),
sizeof
(gUncompressionPixels[0][0]) * 1,
sizeof
(gUncompressionPixels[0][0]) * width,
1, 1,
0.0));
frameBuffer.insert ("B",
Slice (HALF,
(char *)
(&bUncompressionPixels[0][0] - dw.min.x - dw.min.y * width),
sizeof
(bUncompressionPixels[0][0]) * 1,
sizeof
(bUncompressionPixels[0][0]) * width,
1, 1,
0.0));
fileUncompression.setFrameBuffer (frameBuffer);
fileUncompression.readPixels (dw.min.y, dw.max.y);
// apply Piz compression
Header header (width, height);
header.channels().insert ("R", Channel (HALF));
header.channels().insert ("G", Channel (HALF));
header.channels().insert ("B", Channel (HALF));
header.compression() = Imf::PIZ_COMPRESSION;
OutputFile file ("OpenEXR_PizCompression_1x6_red.exr", header);
file.setFrameBuffer (frameBuffer);
file.writePixels (height);
// output another images applied by Piz compression
for (int i = 0;i < height;i++)
{
for (int j = 0; j < width;j++)
{
rUncompressionPixels[i][j] = 0;
gUncompressionPixels[i][j] = 1;
bUncompressionPixels[i][j] = 0;
}
cout << endl;
}
OutputFile file_green ("OpenEXR_PizCompression_1x6_green.exr",
header);
file_green.setFrameBuffer (frameBuffer);
file_green.writePixels (height);
printf("\n - Program finished -");
printf("\n***********************************\n");
system("pause");
return 0;
}
yan
2014.11.27