[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Yafray-devel] Producing HDR images with yafray
From: |
Emmanuel Mogenet |
Subject: |
Re: [Yafray-devel] Producing HDR images with yafray |
Date: |
Thu, 19 May 2005 11:40:15 -0700 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Alfredo de Greef wrote:
Unless you really need tiff format, you are aware that
it is possible to save HDR images in either radiance
.hdr or OpenEXR format? At least in the current cvs it
is.
I didn't know that. I worked in the released code, not in the
cvs head because I needed something stable quick.
I just pulled the cvs head, and yes, I see an OpenEXR io module.
I'll try to play with it if I can figure out how to compile the current
cvs head.
I really would have to see your code, but I can't see
why you would be unable to get the full range.
I've attached my code.
You are using a floatbuffer?
yes
Also make sure that you bypass tonemapping
(exposure/gamma).
That might be the problem.
I'll go play with it now
#ifndef __TIFIO_H
#define __TIFIO_H
#include <string>
#include <stdio.h>
#include "color.h"
#include "buffer.h"
#include "output.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
__BEGIN_YAFRAY
class YAFRAYCORE_EXPORT outTif_t:public colorOutput_t
{
private:
size_t width;
size_t height;
std::string fileName;
float **scanLines;
public:
outTif_t(
size_t _width,
size_t _height,
const char *_fileName
)
:
width(_width),
height(_height),
fileName(_fileName),
scanLines(0)
{
}
virtual ~outTif_t();
virtual bool putPixel(
int x,
int y,
const color_t &color,
CFLOAT alpha=0,
PFLOAT depth=0
);
void flush();
int RX() { return width; };
int RY() { return height; };
};
__END_YAFRAY
#endif //__TIFIO_H
#include <stdlib.h>
#include <tiffio.h>
#include "tifIO.h"
__BEGIN_YAFRAY
bool outTif_t::putPixel(
int x,
int y,
const color_t &color,
CFLOAT alpha,
PFLOAT depth
)
{
if(0<=y && y<(int)height)
{
if(0<=x && x<(int)width)
{
CFLOAT r = color.getRed();
CFLOAT g = color.getGreen();
CFLOAT b = color.getBlue();
CFLOAT a = alpha;
if(
r!=0.0 ||
g!=0.0 ||
b!=0.0 ||
a!=0.0
)
{
if(scanLines==0)
{
size_t arrayByteSize = sizeof(float*)*height;
scanLines = (float**)malloc(arrayByteSize);
memset(scanLines, 0, arrayByteSize);
}
if(scanLines[y]==0)
{
size_t nbChannels = 4;
size_t channelByteSize = sizeof(float);
size_t pixelByteSize = channelByteSize*nbChannels;
size_t scanlineByteSize = pixelByteSize*width;
scanLines[y] = (float*)malloc(scanlineByteSize);
memset(scanLines[y], 0, scanlineByteSize);
}
float *scanLine = scanLines[y];
float *pixel = 4*x + scanLine;
pixel[0] = r;
pixel[1] = g;
pixel[2] = b;
pixel[3] = a;
}
}
}
return true;
}
void outTif_t::flush()
{
TIFF *tif = TIFFOpen(
fileName.c_str(),
"wm"
);
if(tif)
{
//TIFFSetField(tif, TIFFTAG_PREDICTOR, 1);
TIFFSetField(tif, TIFFTAG_XPOSITION, 0.0f);
TIFFSetField(tif, TIFFTAG_YPOSITION, 0.0f);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 16);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8*sizeof(float));
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
const uint16_t info = EXTRASAMPLE_UNASSALPHA;
TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, 1, &info);
size_t nbChannels = 4;
size_t channelByteSize = sizeof(float);
size_t pixelByteSize = channelByteSize*nbChannels;
size_t scanlineByteSize = pixelByteSize*width;
float *black = (float*)malloc(scanlineByteSize);
memset(black, 0, scanlineByteSize);
for(size_t y=0; y<height; ++y)
{
float *scan = scanLines ? scanLines[height-y-1] : 0;
if(scan==0) scan = black;
TIFFWriteScanline(
tif,
(tdata_t)scan,
y,
0
);
}
TIFFClose(tif);
free(black);
}
}
outTif_t::~outTif_t()
{
if(scanLines)
{
for(size_t y=0; y<height; ++y) if(scanLines[y]) free(scanLines[y]);
free(scanLines);
scanLines = 0;
}
}
__END_YAFRAY
- Re: [Yafray-devel] Producing HDR images with yafray, (continued)
- Re: [Yafray-devel] Producing HDR images with yafray, Diego Pino Navarro, 2005/05/18
- Re: [Yafray-devel] Producing HDR images with yafray, Mein, 2005/05/18
- Re: [Yafray-devel] Producing HDR images with yafray, Emmanuel Mogenet, 2005/05/19
- Re: [Yafray-devel] Producing HDR images with yafray, Diego Pino Navarro, 2005/05/19
- Re: [Yafray-devel] Producing HDR images with yafray, Emmanuel Mogenet, 2005/05/19
- [Yafray-devel] Re: Producing HDR images with yafray, GSR - FR, 2005/05/19
- Re: [Yafray-devel] Re: Producing HDR images with yafray, mgix, 2005/05/19
- [Yafray-devel] Re: Re: Producing HDR images with yafray, GSR - FR, 2005/05/19
- Re: [Yafray-devel] Re: Re: Producing HDR images with yafray, Emmanuel Mogenet, 2005/05/19
Re: [Yafray-devel] Producing HDR images with yafray, Alfredo de Greef, 2005/05/19