Normalize colors before writing to final picture
This commit is contained in:
parent
c39ef6adce
commit
04f6ab732d
2 changed files with 11 additions and 7 deletions
|
@ -95,7 +95,6 @@ DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer):
|
|||
_actions->layout()->addWidget(_save_button);
|
||||
|
||||
// Connections
|
||||
connect(this, SIGNAL(progressChanged(double)), this, SLOT(applyProgress(double)));
|
||||
connect(this, SIGNAL(renderEnded()), this, SLOT(applyRenderEnded()));
|
||||
connect(_save_button, SIGNAL(clicked()), this, SLOT(saveRender()));
|
||||
connect(_tonemapping_control, SIGNAL(currentIndexChanged(int)), this, SLOT(toneMappingChanged()));
|
||||
|
|
|
@ -44,16 +44,19 @@ bool CanvasPictureWriter::saveCanvas(const std::string &filepath)
|
|||
|
||||
unsigned int CanvasPictureWriter::getPixel(int x, int y)
|
||||
{
|
||||
Color comp;
|
||||
|
||||
if (antialias > 1)
|
||||
{
|
||||
int basex = x * antialias;
|
||||
int basey = y * 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);
|
||||
comp.r += col.r * factor;
|
||||
|
@ -61,13 +64,15 @@ unsigned int CanvasPictureWriter::getPixel(int x, int y)
|
|||
comp.b += col.b * factor;
|
||||
}
|
||||
}
|
||||
|
||||
return profile->apply(comp).to32BitBGRA();
|
||||
}
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue