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

#include <KoBasicHistogramProducers.h>

+ Inheritance diagram for KoGenericLabHistogramProducer:

Public Member Functions

void addRegionToBin (const quint8 *pixels, const quint8 *selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override
 
QList< KoChannelInfo * > channels () override
 
 KoGenericLabHistogramProducer ()
 
qreal maximalZoom () const override
 
QString positionToString (qreal pos) const override
 
 ~KoGenericLabHistogramProducer () override
 
- Public Member Functions inherited from KoBasicHistogramProducer
void clear () override
 
qint32 count () override
 
qint32 getBinAt (int channel, int position) override
 
const KoIDid () 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< vBinsm_bins
 
int m_channels
 
const KoColorSpacem_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 L*a*b*, and then does its counting. It isCompatibleWith all colorspaces

Definition at line 220 of file KoBasicHistogramProducers.h.

Constructor & Destructor Documentation

◆ KoGenericLabHistogramProducer()

KoGenericLabHistogramProducer::KoGenericLabHistogramProducer ( )

Definition at line 432 of file KoBasicHistogramProducers.cpp.

433 : KoBasicHistogramProducer(KoID("GENLABHISTO", i18n("L*a*b* Histogram")), 3, 256)
434{
435 /* we set 0 as colorspace, because we are not based on a specific colorspace. This
436 is no problem for the superclass since we override channels() */
440
441 if (!m_labCs) {
443 }
445}
static const KoColorSpace * m_labCs
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
const KoColorSpace * lab16(const QString &profileName=QString())
static KoColorSpaceRegistry * instance()

References KoChannelInfo::COLOR, KoColorSpaceRegistry::instance(), KoColorSpaceRegistry::lab16(), m_channelsList, KoBasicHistogramProducer::m_colorSpace, m_labCs, and KoChannelInfo::UINT8.

◆ ~KoGenericLabHistogramProducer()

KoGenericLabHistogramProducer::~KoGenericLabHistogramProducer ( )
override

Definition at line 446 of file KoBasicHistogramProducers.cpp.

447{
448 delete m_channelsList[0];
449 delete m_channelsList[1];
450 delete m_channelsList[2];
451}

References m_channelsList.

Member Function Documentation

◆ addRegionToBin()

void KoGenericLabHistogramProducer::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 469 of file KoBasicHistogramProducers.cpp.

470{
471 for (int i = 0; i < m_channels; i++) {
472 m_outRight[i] = 0;
473 m_outLeft[i] = 0;
474 }
475
476 qint32 dstPixelSize = m_colorSpace->pixelSize();
477
478 quint8 *dstPixels = new quint8[nPixels * dstPixelSize];
480
481 qint32 pSize = cs->pixelSize();
482
483 if (selectionMask) {
484 while (nPixels > 0) {
485 if (!((m_skipUnselected && *selectionMask == 0) || (m_skipTransparent && cs->opacityU8(pixels) == OPACITY_TRANSPARENT_U8))) {
486 m_count++;
487 }
488 pixels += pSize;
489 selectionMask++;
490 nPixels--;
491 }
492 } else {
493 quint8 *dst = dstPixels;
494 while (nPixels > 0) {
495 if (!(m_skipTransparent && cs->opacityU8(pixels) == OPACITY_TRANSPARENT_U8)) {
496
497 m_bins[0][m_colorSpace->scaleToU8(dst, 0)]++;
498 m_bins[1][m_colorSpace->scaleToU8(dst, 1)]++;
499 m_bins[2][m_colorSpace->scaleToU8(dst, 2)]++;
500
501 m_count++;
502 }
503 dst+= dstPixelSize;
504 nPixels--;
505 }
506 }
507 delete[] dstPixels;
508}
const quint8 OPACITY_TRANSPARENT_U8
virtual quint32 pixelSize() const =0
virtual quint8 scaleToU8(const quint8 *srcPixel, qint32 channelPos) const =0

References KoColorSpace::convertPixelsTo(), KoColorConversionTransformation::Empty, KoColorConversionTransformation::IntentAbsoluteColorimetric, KoBasicHistogramProducer::m_bins, KoBasicHistogramProducer::m_channels, KoBasicHistogramProducer::m_colorSpace, KoBasicHistogramProducer::m_count, KoBasicHistogramProducer::m_outLeft, KoBasicHistogramProducer::m_outRight, KoHistogramProducer::m_skipTransparent, KoHistogramProducer::m_skipUnselected, OPACITY_TRANSPARENT_U8, KoColorSpace::opacityU8(), KoColorSpace::pixelSize(), and KoColorSpace::scaleToU8().

◆ channels()

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

Reimplemented from KoBasicHistogramProducer.

Definition at line 453 of file KoBasicHistogramProducers.cpp.

454{
455 return m_channelsList;
456}

References m_channelsList.

◆ maximalZoom()

qreal KoGenericLabHistogramProducer::maximalZoom ( ) const
overridevirtual

Implements KoHistogramProducer.

Definition at line 463 of file KoBasicHistogramProducers.cpp.

464{
465 return 1.0;
466}

◆ positionToString()

QString KoGenericLabHistogramProducer::positionToString ( qreal pos) const
overridevirtual

Implements KoHistogramProducer.

Definition at line 458 of file KoBasicHistogramProducers.cpp.

459{
460 return QString("%1").arg(static_cast<quint16>(pos * UINT16_MAX));
461}
#define UINT16_MAX

References UINT16_MAX.

Member Data Documentation

◆ m_channelsList

QList<KoChannelInfo *> KoGenericLabHistogramProducer::m_channelsList
protected

Definition at line 230 of file KoBasicHistogramProducers.h.


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