File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Color.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "Color.h"
8 
9 #include <QColor>
10 #include <QString>
11 
12 #include "IException.h"
13 
14 namespace Isis {
15 
21  QColor Color::fromRGBAString(QString string) {
22  QColor result;
23 
24  if (colorRGBAFormat().exactMatch(string)) {
25  result = QColor(string.mid(1, 2).toInt(NULL, 16), string.mid(3, 2).toInt(NULL, 16),
26  string.mid(5, 2).toInt(NULL, 16), string.mid(7, 2).toInt(NULL, 16));
27  }
28 
29  return result;
30  }
31 
32 
38  QString Color::toRGBAString(QColor color) {
39  QString result;
40 
41  if (color.isValid()) {
42  result = QString("#%1%2%3%4")
43  .arg(color.red(), 2, 16, QChar('0'))
44  .arg(color.green(), 2, 16, QChar('0'))
45  .arg(color.blue(), 2, 16, QChar('0'))
46  .arg(color.alpha(), 2, 16, QChar('0'));
47  }
48  else {
50  "Can not convert an invalid color to an RGBA string. There is no string representation "
51  "of an invalid color.",
52  _FILEINFO_);
53  }
54 
55  return result;
56  }
57 
58 
65  return QRegExp("^#[0-9a-fA-F]{8}$");
66  }
67 }
Isis::Color::colorRGBAFormat
static QRegExp colorRGBAFormat()
Get the colorRGBAFormat.
Definition: Color.cpp:64
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::Color::toRGBAString
static QString toRGBAString(QColor)
Convert a QColor to its QString.
Definition: Color.cpp:38
Isis::Color::fromRGBAString
static QColor fromRGBAString(QString)
Converts a QString to its QColor.
Definition: Color.cpp:21
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:17