Go to the documentation of this file.
25 #include <QTextStream>
43 return index >= 0 && index <
colors.size();
76 : QObject(), p ( new
Private(*other.p) )
93 : QObject(), p ( other.p )
146 p->
colors.reserve(color_table.size());
147 for ( QRgb c : color_table )
159 if ( image.isNull() )
164 p->
colors.reserve(image.width()*image.height());
165 for (
int y = 0;
y < image.height();
y++ )
167 for (
int x = 0;
x < image.width();
x++ )
169 QColor
color ( image.pixel(
x,
y) );
196 if ( !file.open(QFile::ReadOnly|QFile::Text) )
202 QTextStream stream( &file );
204 if ( stream.readLine() !=
"GIMP Palette" )
213 QHash<QString,QString> properties;
214 while( !stream.atEnd() )
216 line = stream.readLine();
217 if ( line.isEmpty() )
219 if ( line[0] ==
'#' )
221 int colon = line.indexOf(
':');
224 properties[line.left(colon).toLower()] =
225 line.right(line.size() - colon - 1).trimmed();
232 if ( !stream.atEnd() && line[0] ==
'#' )
233 while( !stream.atEnd() )
235 qint64 pos = stream.pos();
236 line = stream.readLine();
237 if ( !line.isEmpty() && line[0] !=
'#' )
244 while( !stream.atEnd() )
246 int r = 0, g = 0, b = 0;
247 stream >> r >> g >> b;
248 line = stream.readLine().trimmed();
249 p->
colors.push_back(qMakePair(QColor(r, g, b), line));
274 if ( filename.isEmpty() )
279 QFile file(filename);
280 if ( !file.open(QFile::Text|QFile::WriteOnly) )
283 QTextStream stream(&file);
285 stream <<
"GIMP Palette\n";
288 stream <<
"Columns: " <<
p->
columns <<
'\n';
292 for (
int i = 0; i <
p->
colors.size(); i++ )
294 stream << qSetFieldWidth(3) <<
p->
colors[i].first.red() << qSetFieldWidth(0) <<
' '
295 << qSetFieldWidth(3) <<
p->
colors[i].first.green() << qSetFieldWidth(0) <<
' '
296 << qSetFieldWidth(3) <<
p->
colors[i].first.blue() << qSetFieldWidth(0) <<
'\t'
331 foreach(
const QColor& col,
colors)
332 p->
colors.push_back(qMakePair(col,QString()));
392 if ( index < 0 || index >
p->
colors.size() )
428 return name.isEmpty() ? tr(
"Unnamed") :
name;
438 out.fill(background);
439 QPainter painter(&out);
446 QSizeF color_size(
float(
size.width()) /
columns,
float(
size.height()) / rows);
448 for (
int y = 0, i = 0;
y < rows && i <
count;
y++ )
452 painter.fillRect(QRectF(
x*color_size.width(),
y*color_size.height(),
453 color_size.width(), color_size.height()),
477 for (
int i = 0; i <
p->
colors.size(); i++ )
478 out.push_back(
p->
colors[i].first);
486 for (
const auto& color_pair :
p->
colors )
487 out.push_back(color_pair.first.rgba());
span_constexpr std::size_t size(span< T, Extent > const &spn)
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43