67{
68 Private::ProcessData *d_pd = dynamic_cast<Private::ProcessData*>(data);
69
70 if (!d_pd) {
72 return;
73 }
74
75 QRect calculate = d_pd->rectToCalculate;
76
78 QRect imageBounds =
m_d->image->bounds();
79
83
84 int imageSize = imageBounds.width() * imageBounds.height();
85 int nSkip = 1 + (imageSize >> 20);
86
87 if (calculate.isEmpty())
88 return;
89
92
93 quint32 toSkip = nSkip;
94
95 float maximum = 1.0;
99
100 int numConseqPixels = it.nConseqPixels();
101 while (it.nextPixels(numConseqPixels)) {
102 numConseqPixels = it.nConseqPixels();
103 const quint8* pixel = it.rawDataConst();
104 for (int k = 0; k < numConseqPixels; ++k) {
106 for (int chan = 0; chan < (int)channelCount; ++chan) {
107 maximum = qMax(maximum, channelValues.at(chan));
108 }
109 pixel += pixelSize;
110 }
111 }
112 }
113 m_d->maximumValue = maximum;
114
115 const double maximumMultiplier = 255.0/maximum;
116 const double logMaxMultiplier = 255.0/(std::log10(maximum*10)*0.1);
117
118
120
121 int numConseqPixels = it.nConseqPixels();
122 while (it.nextPixels(numConseqPixels)) {
123
124 numConseqPixels = it.nConseqPixels();
125 const quint8* pixel = it.rawDataConst();
126 for (int k = 0; k < numConseqPixels; ++k) {
128 if (--toSkip == 0) {
129
130 for (int chan = 0; chan < (int)channelCount; ++chan) {
131 m_d->results[d_pd->jobId][chan][ qBound(0, qRound(channelValues.at(chan)*maximumMultiplier), 255) ]++;
132 m_d->resultsLog[d_pd->jobId][chan][ qBound(0, qRound(std::log10(channelValues.at(chan)*10)*0.1*logMaxMultiplier), 255) ]++;
133 }
134 toSkip = nSkip;
135 }
136 pixel += pixelSize;
137 }
138 }
139}
void initiateVector(HistVector &vec, const KoColorSpace *colorSpace)
quint32 pixelSize() const
quint32 channelCount() const
const KoColorSpace * colorSpace() const
virtual void doStrokeCallback(KisStrokeJobData *data)
virtual bool hasHighDynamicRange() const =0
virtual void normalisedChannelsValue(const quint8 *pixel, QVector< float > &channels) const =0