Fix .gpl loader to ignore extra properties in the file

This commit is contained in:
David Capello 2014-04-12 14:30:19 -03:00
parent 1ab782b85d
commit 6aa4149dec

View File

@ -30,6 +30,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <iomanip> #include <iomanip>
#include <cctype>
namespace raster { namespace raster {
namespace file { namespace file {
@ -56,8 +57,13 @@ Palette* load_gpl_file(const char *filename)
if (line.empty() || line[0] == '#') if (line.empty() || line[0] == '#')
continue; continue;
// Remove properties (TODO add these properties in the palette)
if (!std::isdigit(line[0]))
continue;
int r, g, b; int r, g, b;
std::istringstream lineIn(line); std::istringstream lineIn(line);
// TODO add support to read the color name
lineIn >> r >> g >> b; lineIn >> r >> g >> b;
if (lineIn.good()) { if (lineIn.good()) {
pal->setEntry(entryCounter, rgba(r, g, b, 255)); pal->setEntry(entryCounter, rgba(r, g, b, 255));