From d1cc4a53f5492d95c260a7871cc030c9b1b0a6e9 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sat, 10 Mar 2018 15:59:48 +0100 Subject: Add color scaling option (as 8 bit per channel is not really much) --- BuddhaTest/src/Helpers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'BuddhaTest/src/Helpers.cpp') diff --git a/BuddhaTest/src/Helpers.cpp b/BuddhaTest/src/Helpers.cpp index bde6b8a..eacaf5d 100644 --- a/BuddhaTest/src/Helpers.cpp +++ b/BuddhaTest/src/Helpers.cpp @@ -155,7 +155,7 @@ namespace Helpers return ProgramID; } - void WriteOutputPNG(const std::vector& data, unsigned int width, unsigned int bufferHeight, double gamma) + void WriteOutputPNG(const std::vector& data, unsigned int width, unsigned int bufferHeight, double gamma, double colorScale) { std::vector pngData(3*width*2*bufferHeight); std::vector rows{2*bufferHeight}; @@ -171,9 +171,9 @@ namespace Helpers } for(unsigned int i = 0; i < data.size();++i) { - if(fabs(gamma - 1.0) > 0.0001) + if(fabs(gamma - 1.0) > 0.0001 || fabs(colorScale - 1.0) > 0.0001) { - pngData[data.size() + i] = 255.0 * pow(static_cast(data[i])/static_cast(maxValue),gamma); + pngData[data.size() + i] = 255.0 * pow(std::min(1.0,colorScale*static_cast(data[i])/static_cast(maxValue)),gamma); } else { -- cgit v1.2.3