QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgscolorutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscolorutils.h
3 ---------------------------
4 begin : July 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSCOLORUTILS_H
19#define QGSCOLORUTILS_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgis_sip.h"
24
25#include <QColorSpace>
26#include <QDomDocument>
27#include <QDomElement>
28
30
37class CORE_EXPORT QgsColorUtils
38{
39 public:
40
55 static void writeXml( const QColor &color, const QString &identifier,
56 QDomDocument &document, QDomElement &element, const QgsReadWriteContext &context );
57
70 static QColor readXml( const QDomElement &element, const QString &identifier, const QgsReadWriteContext &context );
71
82 static QString colorToString( const QColor &color );
83
96 static QColor colorFromString( const QString &string );
97
109 static QColorSpace iccProfile( const QString &iccProfileFilePath, QString &errorMsg SIP_OUT );
110
117 static QString saveIccProfile( const QColorSpace &colorSpace, const QString &iccProfileFilePath );
118
119
120#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
121
129 static Qgis::ColorModel toColorModel( QColorSpace::ColorModel colorModel, bool *ok = nullptr ) SIP_SKIP;
130
131#endif
132
133};
134
135#endif // QGSCOLORUTILS_H
ColorModel
Color model types.
Definition qgis.h:5986
Contains utility functions for working with colors.
static QColor readXml(const QDomElement &element, const QString &identifier, const QgsReadWriteContext &context)
Reads a color from an XML element, matching the specified identifier string.
static void writeXml(const QColor &color, const QString &identifier, QDomDocument &document, QDomElement &element, const QgsReadWriteContext &context)
Writes a color to an XML element, storing it under the specified identifier.
static Qgis::ColorModel toColorModel(QColorSpace::ColorModel colorModel, bool *ok=nullptr)
Convert and returns Qt colorModel to Qgis::ColorModel.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
static QColorSpace iccProfile(const QString &iccProfileFilePath, QString &errorMsg)
Loads an ICC profile from iccProfileFilePath and returns associated color space.
static QString saveIccProfile(const QColorSpace &colorSpace, const QString &iccProfileFilePath)
Save color space colorSpace to an ICC profile file iccProfileFilePath.
A container for the context for various read/write operations on objects.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_OUT
Definition qgis_sip.h:58