Krita Source Code Documentation
Loading...
Searching...
No Matches
KoChannelInfo Class Reference

#include <KoChannelInfo.h>

Classes

struct  DoubleRange
 

Public Types

enum  enumChannelType { COLOR , ALPHA }
 enum to define the type of the channel More...
 
enum  enumChannelValueType {
  UINT8 , UINT16 , UINT32 , FLOAT16 ,
  FLOAT32 , FLOAT64 , INT8 , INT16 ,
  OTHER
}
 enum to define the value of the channel More...
 

Public Member Functions

enumChannelType channelType () const
 
enumChannelValueType channelValueType () const
 
QColor color () const
 
qint32 displayPosition () const
 
double getUIMax (void) const
 
double getUIMin (void) const
 
double getUIUnitValue (void) const
 getUIUnitValue Gets the unit value for this channel. This is suitable for converting between representations.
 
 KoChannelInfo ()
 
 KoChannelInfo (const QString &name, qint32 npos, qint32 displayPosition, enumChannelType channelType, enumChannelValueType channelValueType, qint32 size=-1, const QColor &color=QColor(0, 0, 0), const DoubleRange &uiMinMax=DoubleRange())
 
QString name () const
 
bool operator< (const KoChannelInfo &info)
 
qint32 pos () const
 
qint32 size () const
 

Static Public Member Functions

static QList< KoChannelInfo * > displayOrderSorted (const QList< KoChannelInfo * > &channels)
 
static int displayPositionToChannelIndex (int displayPosition, const QList< KoChannelInfo * > &channels)
 

Private Attributes

enumChannelType m_channelType
 
enumChannelValueType m_channelValueType
 
QColor m_color
 
qint32 m_displayPosition
 
QString m_name
 
qint32 m_pos
 
qint32 m_size
 
DoubleRange m_uiMinMax
 

Detailed Description

This class gives some basic information about a channel, that is, one of the components that makes up a particular pixel.

Definition at line 21 of file KoChannelInfo.h.

Member Enumeration Documentation

◆ enumChannelType

enum to define the type of the channel

Enumerator
COLOR 

The channel represents a color.

ALPHA 

The channel represents the opacity of a pixel.

Definition at line 41 of file KoChannelInfo.h.

41 {
42 COLOR,
43 ALPHA
44 //SUBSTANCE, ///< The channel represents a real-world substance like pigments or medium
45 //SUBSTRATE ///< The channel represents a real-world painting substrate like a canvas
46 };
@ ALPHA
The channel represents the opacity of a pixel.
@ COLOR
The channel represents a color.

◆ enumChannelValueType

enum to define the value of the channel

Enumerator
UINT8 

use this for an unsigned integer 8bits channel

UINT16 

use this for an integer 16bits channel

UINT32 

use this for an unsigned integer 21bits channel

FLOAT16 

use this for a float 16bits channel

FLOAT32 

use this for a float 32bits channel

FLOAT64 

use this for a float 64bits channel

INT8 

use this for an integer 8bits channel

INT16 

use this for an integer 16bits channel

OTHER 

Use this if the channel is neither an integer or a float.

Definition at line 48 of file KoChannelInfo.h.

48 {
49 UINT8,
50 UINT16,
51 UINT32,
52 FLOAT16,
53 FLOAT32,
54 FLOAT64,
55 INT8,
56 INT16,
57 OTHER
58 };
@ UINT8
use this for an unsigned integer 8bits channel
@ UINT16
use this for an integer 16bits channel
@ OTHER
Use this if the channel is neither an integer or a float.
@ INT16
use this for an integer 16bits channel
@ INT8
use this for an integer 8bits channel
@ FLOAT32
use this for a float 32bits channel
@ FLOAT16
use this for a float 16bits channel
@ UINT32
use this for an unsigned integer 21bits channel
@ FLOAT64
use this for a float 64bits channel

Constructor & Destructor Documentation

◆ KoChannelInfo() [1/2]

KoChannelInfo::KoChannelInfo ( )
inline

Definition at line 61 of file KoChannelInfo.h.

61{ }

◆ KoChannelInfo() [2/2]

KoChannelInfo::KoChannelInfo ( const QString & name,
qint32 npos,
qint32 displayPosition,
enumChannelType channelType,
enumChannelValueType channelValueType,
qint32 size = -1,
const QColor & color = QColor(0, 0, 0),
const DoubleRange & uiMinMax = DoubleRange() )
inline
Parameters
nameof the channel
nposposition of the channel in the pixel (in bytes)
displayPositionthe position of the channel in the user-visible order
channelTypetype of the channel
channelValueTypetype of the numerical data used by the channel
sizenumber of bytes (not bits) of the channel (if -1, it is deduced from the channelType)
colora color to represent that channel (for instance in an histogram)
uiMinMaxthe UI range

Definition at line 72 of file KoChannelInfo.h.

80 : m_name(name)
81 , m_pos(npos)
85 , m_size(size)
86 , m_color(color)
87 , m_uiMinMax(uiMinMax)
88 {
89 switch(m_channelValueType)
90 {
91 case UINT8:
92 case INT8:
93 Q_ASSERT(m_size == -1 || m_size == 1);
94 m_size = 1;
95 break;
96 case UINT16:
97 case INT16:
98 Q_ASSERT(m_size == -1 || m_size == 2);
99 m_size = 2;
100 break;
101 case UINT32:
102 Q_ASSERT(m_size == -1 || m_size == 4);
103 m_size = 4;
104 break;
105 case FLOAT16:
106 Q_ASSERT(m_size == -1 || m_size == 2);
107 m_size = 2;
108 break;
109 case FLOAT32:
110 Q_ASSERT(m_size == -1 || m_size == 4);
111 m_size = 4;
112 break;
113 case FLOAT64:
114 Q_ASSERT(m_size == -1 || m_size == 8);
115 m_size = 8;
116 break;
117 case OTHER:
118 Q_ASSERT(m_size != -1);
119 }
120 if (!uiMinMax.isValid()) {
121 switch (m_channelValueType) {
122 case UINT8:
123 m_uiMinMax.minVal = std::numeric_limits<quint8>::min();
124 m_uiMinMax.maxVal = std::numeric_limits<quint8>::max();
125 break;
126 case INT8:
127 m_uiMinMax.minVal = std::numeric_limits<qint8>::min();
128 m_uiMinMax.maxVal = std::numeric_limits<qint8>::max();
129 break;
130 case UINT16:
131 m_uiMinMax.minVal = std::numeric_limits<quint16>::min();
132 m_uiMinMax.maxVal = std::numeric_limits<quint16>::max();
133 break;
134 case INT16:
135 m_uiMinMax.minVal = std::numeric_limits<qint16>::min();
136 m_uiMinMax.maxVal = std::numeric_limits<qint16>::max();
137 break;
138 case UINT32:
139 m_uiMinMax.minVal = std::numeric_limits<quint32>::min();
140 m_uiMinMax.maxVal = std::numeric_limits<quint32>::max();
141 break;
142 default:
143 // assume real otherwise, which is 0..1 by default
144 m_uiMinMax.minVal = 0.0;
145 m_uiMinMax.maxVal = 1.0;
146 break;
147 }
148 }
149 Q_ASSERT(m_uiMinMax.isValid());
150 }
QColor color() const
qint32 size() const
enumChannelType channelType() const
enumChannelType m_channelType
enumChannelValueType channelValueType() const
qint32 m_displayPosition
QString name() const
enumChannelValueType m_channelValueType
qint32 displayPosition() const
DoubleRange m_uiMinMax
bool isValid(void) const
true if this range is usable

References FLOAT16, FLOAT32, FLOAT64, INT16, INT8, KoChannelInfo::DoubleRange::isValid(), m_channelValueType, m_size, m_uiMinMax, KoChannelInfo::DoubleRange::maxVal, KoChannelInfo::DoubleRange::minVal, OTHER, UINT16, UINT32, and UINT8.

Member Function Documentation

◆ channelType()

enumChannelType KoChannelInfo::channelType ( ) const
inline
Returns
the type of the channel

Definition at line 212 of file KoChannelInfo.h.

212 {
213 return m_channelType;
214 }

References m_channelType.

◆ channelValueType()

enumChannelValueType KoChannelInfo::channelValueType ( ) const
inline
Returns
the type of the value of the channel (float, uint8 or uint16)

Definition at line 218 of file KoChannelInfo.h.

218 {
219 return m_channelValueType;
220 }

References m_channelValueType.

◆ color()

QColor KoChannelInfo::color ( ) const
inline

This is a color that can be used to represent this channel in histograms and so. By default this is black, so keep in mind that many channels might look the same

Definition at line 225 of file KoChannelInfo.h.

225 {
226 return m_color;
227 }

References m_color.

◆ displayOrderSorted()

static QList< KoChannelInfo * > KoChannelInfo::displayOrderSorted ( const QList< KoChannelInfo * > & channels)
inlinestatic

Definition at line 166 of file KoChannelInfo.h.

167 {
168 QList <KoChannelInfo*> sortedChannels;
169 for (int i = 0; i < channels.size(); ++i) {
170 Q_FOREACH (KoChannelInfo* channel, channels) {
171 if (channel->displayPosition() == i) {
172 sortedChannels << channel;
173 break;
174 }
175 }
176 }
177 Q_ASSERT(channels.size() == sortedChannels.size());
178 return sortedChannels;
179 }

References displayPosition().

◆ displayPosition()

qint32 KoChannelInfo::displayPosition ( ) const
inline
Returns
the displayPosition of the channel in the pixel

Definition at line 198 of file KoChannelInfo.h.

198 {
199 return m_displayPosition;
200 }

References m_displayPosition.

◆ displayPositionToChannelIndex()

static int KoChannelInfo::displayPositionToChannelIndex ( int displayPosition,
const QList< KoChannelInfo * > & channels )
inlinestatic

converts the display position to the pixel-order index in the channels vector.

Definition at line 156 of file KoChannelInfo.h.

157 {
158 for (int i = 0; i < channels.size(); ++i) {
159 if (channels.at(i)->displayPosition() == displayPosition) {
160 return i;
161 }
162 }
163 return -1;
164 }

References displayPosition().

◆ getUIMax()

double KoChannelInfo::getUIMax ( void ) const
inline

Gets the minimum value that this channel should have. This is suitable for UI use.

Definition at line 248 of file KoChannelInfo.h.

248 {
249 return m_uiMinMax.maxVal;
250 }

References m_uiMinMax, and KoChannelInfo::DoubleRange::maxVal.

◆ getUIMin()

double KoChannelInfo::getUIMin ( void ) const
inline

Gets the minimum value that this channel should have. This is suitable for UI use.

Definition at line 240 of file KoChannelInfo.h.

240 {
241 return m_uiMinMax.minVal;
242 }

References m_uiMinMax, and KoChannelInfo::DoubleRange::minVal.

◆ getUIUnitValue()

double KoChannelInfo::getUIUnitValue ( void ) const
inline

getUIUnitValue Gets the unit value for this channel. This is suitable for converting between representations.

Definition at line 257 of file KoChannelInfo.h.

257 {
259 }

References m_uiMinMax, KoChannelInfo::DoubleRange::maxVal, and KoChannelInfo::DoubleRange::minVal.

◆ name()

QString KoChannelInfo::name ( ) const
inline

User-friendly name for this channel for presentation purposes in the gui

Definition at line 184 of file KoChannelInfo.h.

184 {
185 return m_name;
186 }

References m_name.

◆ operator<()

bool KoChannelInfo::operator< ( const KoChannelInfo & info)
inline

A channel is less than another channel if its pos is smaller.

Definition at line 232 of file KoChannelInfo.h.

232 {
233 return m_pos < info.m_pos;
234 }

References m_pos.

◆ pos()

qint32 KoChannelInfo::pos ( ) const
inline
Returns
the position of the first byte of the channel in the pixel

Definition at line 191 of file KoChannelInfo.h.

191 {
192 return m_pos;
193 }

References m_pos.

◆ size()

qint32 KoChannelInfo::size ( ) const
inline
Returns
the number of bytes this channel takes

Definition at line 205 of file KoChannelInfo.h.

205 {
206 return m_size;
207 }

References m_size.

Member Data Documentation

◆ m_channelType

enumChannelType KoChannelInfo::m_channelType
private

Definition at line 266 of file KoChannelInfo.h.

◆ m_channelValueType

enumChannelValueType KoChannelInfo::m_channelValueType
private

Definition at line 267 of file KoChannelInfo.h.

◆ m_color

QColor KoChannelInfo::m_color
private

Definition at line 269 of file KoChannelInfo.h.

◆ m_displayPosition

qint32 KoChannelInfo::m_displayPosition
private

Definition at line 265 of file KoChannelInfo.h.

◆ m_name

QString KoChannelInfo::m_name
private

Definition at line 263 of file KoChannelInfo.h.

◆ m_pos

qint32 KoChannelInfo::m_pos
private

Definition at line 264 of file KoChannelInfo.h.

◆ m_size

qint32 KoChannelInfo::m_size
private

Definition at line 268 of file KoChannelInfo.h.

◆ m_uiMinMax

DoubleRange KoChannelInfo::m_uiMinMax
private

Definition at line 270 of file KoChannelInfo.h.


The documentation for this class was generated from the following file: