From 4a2255f1996f8a0eccf05226ec129b09cf6c4151 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 11 Sep 2013 21:01:16 -0500 Subject: use background color when writing PNG with lodepng diff --git a/src/imageutils-lodepng.cc b/src/imageutils-lodepng.cc index cd104d6..9f3afda 100644 --- a/src/imageutils-lodepng.cc +++ b/src/imageutils-lodepng.cc @@ -5,11 +5,20 @@ #include #include #include +#include "rendersettings.h" bool write_png(std::ostream &output, unsigned char *pixels, int width, int height) { std::vector dataout; - unsigned err = lodepng::encode(dataout, pixels, width, height, LCT_RGBA, 8); + lodepng::State state; + state.info_png.background_defined = true; + Color4f bg = RenderSettings::inst()->color(RenderSettings::BACKGROUND_COLOR); + state.info_png.background_r = bg(0); + state.info_png.background_g = bg(1); + state.info_png.background_b = bg(2); + state.info_png.color.colortype = LCT_RGBA; + state.info_png.color.bitdepth = 8; + unsigned err = lodepng::encode(dataout, pixels, width, height, state); if ( err ) return false; output.write( reinterpret_cast(&dataout[0]), dataout.size()); if ( output.bad() ) std::cerr << "Error writing to ostream\n"; -- cgit v0.10.1