Normalize colors before writing to final picture

This commit is contained in:
Michaël Lemaire 2014-08-21 14:53:49 +02:00
parent c39ef6adce
commit 04f6ab732d
2 changed files with 11 additions and 7 deletions

View file

@ -95,7 +95,6 @@ DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer):
_actions->layout()->addWidget(_save_button); _actions->layout()->addWidget(_save_button);
// Connections // Connections
connect(this, SIGNAL(progressChanged(double)), this, SLOT(applyProgress(double)));
connect(this, SIGNAL(renderEnded()), this, SLOT(applyRenderEnded())); connect(this, SIGNAL(renderEnded()), this, SLOT(applyRenderEnded()));
connect(_save_button, SIGNAL(clicked()), this, SLOT(saveRender())); connect(_save_button, SIGNAL(clicked()), this, SLOT(saveRender()));
connect(_tonemapping_control, SIGNAL(currentIndexChanged(int)), this, SLOT(toneMappingChanged())); connect(_tonemapping_control, SIGNAL(currentIndexChanged(int)), this, SLOT(toneMappingChanged()));

View file

@ -44,16 +44,19 @@ bool CanvasPictureWriter::saveCanvas(const std::string &filepath)
unsigned int CanvasPictureWriter::getPixel(int x, int y) unsigned int CanvasPictureWriter::getPixel(int x, int y)
{ {
Color comp;
if (antialias > 1) if (antialias > 1)
{ {
int basex = x * antialias; int basex = x * antialias;
int basey = y * antialias; int basey = y * antialias;
double factor = 1.0 / (antialias * antialias); double factor = 1.0 / (antialias * antialias);
Color comp = COLOR_BLACK;
for (int ix = 0; ix < antialias; ix++) comp = COLOR_BLACK;
{
for (int iy = 0; iy < antialias; iy++) for (int iy = 0; iy < antialias; iy++)
{
for (int ix = 0; ix < antialias; ix++)
{ {
Color col = getRawPixel(basex + ix, basey + iy); Color col = getRawPixel(basex + ix, basey + iy);
comp.r += col.r * factor; comp.r += col.r * factor;
@ -61,13 +64,15 @@ unsigned int CanvasPictureWriter::getPixel(int x, int y)
comp.b += col.b * factor; comp.b += col.b * factor;
} }
} }
return profile->apply(comp).to32BitBGRA();
} }
else else
{ {
return profile->apply(getRawPixel(x, y)).to32BitBGRA(); comp = getRawPixel(x, y);
} }
comp = profile->apply(comp);
comp.normalize();
return comp.to32BitBGRA();
} }
Color CanvasPictureWriter::getRawPixel(int x, int y) Color CanvasPictureWriter::getRawPixel(int x, int y)