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

#include <KoBasicHistogramProducers.h>

+ Inheritance diagram for KoGenericRGBHistogramProducer:

Public Member Functions

void addRegionToBin (const quint8 *pixels, const quint8 *selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override
 
QList< KoChannelInfo * > channels () override
 
 KoGenericRGBHistogramProducer ()
 
qreal maximalZoom () const override
 
QString positionToString (qreal pos) const override
 
 ~KoGenericRGBHistogramProducer () override
 
- Public Member Functions inherited from KoBasicHistogramProducer
void clear () override
 
qint32 count () override
 
qint32 getBinAt (int channel, int position) override
 
const KoID & id () const override
 
 KoBasicHistogramProducer (const KoID &id, int channelCount, int nrOfBins)
 
 KoBasicHistogramProducer (const KoID &id, int nrOfBins, const KoColorSpace *colorSpace)
 
qint32 numberOfBins () override
 
qint32 outOfViewLeft (int channel) override
 
qint32 outOfViewRight (int channel) override
 
void setView (qreal from, qreal size) override
 
qreal viewFrom () const override
 
qreal viewWidth () const override
 
 ~KoBasicHistogramProducer () override
 
- Public Member Functions inherited from KoHistogramProducer
virtual qint32 getBinAt (qint32 channel, qint32 position)=0
 
 KoHistogramProducer ()
 
virtual qint32 outOfViewLeft (qint32 channel)=0
 
virtual qint32 outOfViewRight (qint32 channel)=0
 
virtual void setSkipTransparent (bool set)
 
virtual void setSkipUnselected (bool set)
 
virtual ~KoHistogramProducer ()
 

Protected Attributes

QList< KoChannelInfo * > m_channelsList
 
- Protected Attributes inherited from KoBasicHistogramProducer
QVector< vBins > m_bins
 
int m_channels
 
const KoColorSpace * m_colorSpace
 
qint32 m_count
 
QVector< qint32 > m_external
 
qreal m_from
 
KoID m_id
 
int m_nrOfBins
 
vBins m_outLeft
 
vBins m_outRight
 
qreal m_width
 
- Protected Attributes inherited from KoHistogramProducer
bool m_skipTransparent
 
bool m_skipUnselected
 

Additional Inherited Members

- Protected Types inherited from KoBasicHistogramProducer
typedef QVector< quint32 > vBins
 
- Protected Member Functions inherited from KoBasicHistogramProducer
virtual int externalToInternal (int ext)
 
void makeExternalToInternal ()
 

Detailed Description

This is a Producer (with associated factory) that converts the pixels of the colorspace to RGB8 with toQColor, and then does its counting on RGB. This is NOT registered with the Registry, because it isCompatibleWith all colorspaces, and should only be used in extreme cases (like no other producer being available

Definition at line 179 of file KoBasicHistogramProducers.h.

Constructor & Destructor Documentation

◆ KoGenericRGBHistogramProducer()

KoGenericRGBHistogramProducer::KoGenericRGBHistogramProducer ( )

Definition at line 363 of file KoBasicHistogramProducers.cpp.

364 : KoBasicHistogramProducer(KoID("GENRGBHISTO", i18n("Generic RGB Histogram")), 3, 256)
365{
366 /* we set 0 as colorspace, because we are not based on a specific colorspace. This
367 is no problem for the superclass since we override channels() */
368 m_channelsList.append(new KoChannelInfo(i18n("R"), 0, 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(255, 0, 0)));
369 m_channelsList.append(new KoChannelInfo(i18n("G"), 1, 1, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 255, 0)));
370 m_channelsList.append(new KoChannelInfo(i18n("B"), 2, 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 0, 255)));
371}
KoBasicHistogramProducer(const KoID &id, int channelCount, int nrOfBins)
@ COLOR
The channel represents a color.
@ UINT8
use this for an unsigned integer 8bits channel
Definition KoID.h:30

References KoChannelInfo::COLOR, m_channelsList, and KoChannelInfo::UINT8.

◆ ~KoGenericRGBHistogramProducer()

KoGenericRGBHistogramProducer::~KoGenericRGBHistogramProducer ( )
override

Definition at line 372 of file KoBasicHistogramProducers.cpp.

373{
374 delete m_channelsList[0];
375 delete m_channelsList[1];
376 delete m_channelsList[2];
377}

References m_channelsList.

Member Function Documentation

◆ addRegionToBin()

void KoGenericRGBHistogramProducer::addRegionToBin ( const quint8 * pixels,
const quint8 * selectionMask,
quint32 nPixels,
const KoColorSpace * colorSpace )
overridevirtual

Adds the values from the specified array of pixels to the bins – does not reset anything.

Parameters
pixelsA pointer an array of pixeldata in the given colorspace
selectionMaska pointer to an array of bytes, where 0 is unselected and 1-255 is degree of selectedness. The array must be just as long as the array of pixels.
nPixelsThe number of pixels
colorSpacethe colorspace that can decode the pixel data.

Implements KoHistogramProducer.

Definition at line 395 of file KoBasicHistogramProducers.cpp.

396{
397 for (int i = 0; i < m_channels; i++) {
398 m_outRight[i] = 0;
399 m_outLeft[i] = 0;
400 }
401
402 QColor c;
403 qint32 pSize = cs->pixelSize();
404 if (selectionMask) {
405 while (nPixels > 0) {
406 if (!((m_skipUnselected && *selectionMask == 0) || (m_skipTransparent && cs->opacityU8(pixels) == OPACITY_TRANSPARENT_U8))) {
407 cs->toQColor(pixels, &c);
408 m_bins[0][c.red()]++;
409 m_bins[1][c.green()]++;
410 m_bins[2][c.blue()]++;
411
412 m_count++;
413 }
414 pixels += pSize;
415 selectionMask++;
416 nPixels--;
417 }
418
419 } else {
420 while (nPixels > 0) {
421
422 if (!(m_skipTransparent && cs->opacityU8(pixels) == OPACITY_TRANSPARENT_U8)) {
423 cs->toQColor(pixels, &c);
424 m_bins[0][c.red()]++;
425 m_bins[1][c.green()]++;
426 m_bins[2][c.blue()]++;
427
428 m_count++;
429 }
430 pixels += pSize;
431 nPixels--;
432 }
433 }
434}
const quint8 OPACITY_TRANSPARENT_U8

References KoBasicHistogramProducer::m_bins, KoBasicHistogramProducer::m_channels, KoBasicHistogramProducer::m_count, KoBasicHistogramProducer::m_outLeft, KoBasicHistogramProducer::m_outRight, KoHistogramProducer::m_skipTransparent, KoHistogramProducer::m_skipUnselected, OPACITY_TRANSPARENT_U8, KoColorSpace::opacityU8(), KoColorSpace::pixelSize(), and KoColorSpace::toQColor().

◆ channels()

QList< KoChannelInfo * > KoGenericRGBHistogramProducer::channels ( )
overridevirtual

Reimplemented from KoBasicHistogramProducer.

Definition at line 379 of file KoBasicHistogramProducers.cpp.

380{
381 return m_channelsList;
382}

References m_channelsList.

◆ maximalZoom()

qreal KoGenericRGBHistogramProducer::maximalZoom ( ) const
overridevirtual

Implements KoHistogramProducer.

Definition at line 389 of file KoBasicHistogramProducers.cpp.

390{
391 return 1.0;
392}

◆ positionToString()

QString KoGenericRGBHistogramProducer::positionToString ( qreal pos) const
overridevirtual

Implements KoHistogramProducer.

Definition at line 384 of file KoBasicHistogramProducers.cpp.

385{
386 return QString("%1").arg(static_cast<quint8>(pos * UINT8_MAX));
387}
#define UINT8_MAX

References UINT8_MAX.

Member Data Documentation

◆ m_channelsList

QList<KoChannelInfo *> KoGenericRGBHistogramProducer::m_channelsList
protected

Definition at line 189 of file KoBasicHistogramProducers.h.


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