6#include "chromahueimageparameters.h"
8#include "asyncimagerendercallback.h"
9#include "cielchd50values.h"
10#include "helperconstants.h"
11#include "helpermath.h"
12#include "interlacingpass.h"
13#include "rgbcolorspace.h"
18#include <qnamespace.h>
21#include <qsharedpointer.h>
32bool ChromaHueImageParameters::operator==(
const ChromaHueImageParameters &other)
const
35 (borderPhysical == other.borderPhysical)
36 && (devicePixelRatioF == other.devicePixelRatioF)
37 && (imageSizePhysical == other.imageSizePhysical)
38 && (lightness == other.lightness)
39 && (rgbColorSpace == other.rgbColorSpace)
48bool ChromaHueImageParameters::operator!=(
const ChromaHueImageParameters &other)
const
50 return !(*
this == other);
70void ChromaHueImageParameters::render(
const QVariant &variantParameters, AsyncImageRenderCallback &callbackObject)
72 if (!variantParameters.
canConvert<ChromaHueImageParameters>()) {
75 const ChromaHueImageParameters parameters =
76 variantParameters.
value<ChromaHueImageParameters>();
85 if (callbackObject.shouldAbort()) {
91 QSize(parameters.imageSizePhysical, parameters.imageSizePhysical),
97 const qreal circleRadius =
98 (parameters.imageSizePhysical - 2 * parameters.borderPhysical) / 2.;
99 if ((circleRadius <= 0) || parameters.rgbColorSpace.isNull()) {
108 myImage.setDevicePixelRatio(parameters.devicePixelRatioF);
109 callbackObject.deliverInterlacingPass(
112 AsyncImageRenderCallback::InterlacingState::Final);
118 const QColor myNeutralGray =
119 parameters.rgbColorSpace->fromCielchD50ToQRgbBound(CielchD50Values::neutralGray);
123 myImage.fill(myNeutralGray);
131 const auto chromaRange = parameters.rgbColorSpace->profileMaximumCielchD50Chroma();
132 const qreal scaleFactor =
static_cast<qreal
>(2 * chromaRange)
136 / (parameters.imageSizePhysical - 2 * parameters.borderPhysical);
146 constexpr qreal pixelOffset = 0.5;
152 constexpr auto numberOfPasses = 11;
153 static_assert(isOdd(numberOfPasses));
154 InterlacingPass currentPass = InterlacingPass::make<numberOfPasses>();
158 for (y = currentPass.lineOffset;
159 y < parameters.imageSizePhysical;
160 y += currentPass.lineFrequency)
162 if (callbackObject.shouldAbort()) {
165 cielabD50.b = chromaRange
166 - (y + pixelOffset - parameters.borderPhysical) * scaleFactor;
167 for (x = currentPass.columnOffset;
168 x < parameters.imageSizePhysical;
169 x += currentPass.columnFrequency
172 (x + pixelOffset - parameters.borderPhysical) * scaleFactor
175 (qPow(cielabD50.a, 2) + qPow(cielabD50.b, 2))
176 <= (qPow(chromaRange + overlap, 2))
178 tempColor = parameters
180 ->fromCielabD50ToQRgbOrTransparent(cielabD50);
181 if (qAlpha(tempColor) != 0) {
187 currentPass.rectangleSize.width(),
188 currentPass.rectangleSize.height(),
195 currentPass.rectangleSize.width(),
196 currentPass.rectangleSize.height(),
203 const AsyncImageRenderCallback::InterlacingState state =
204 (currentPass.countdown > 1)
205 ? AsyncImageRenderCallback::InterlacingState::Intermediate
206 : AsyncImageRenderCallback::InterlacingState::Final;
208 myImage.setDevicePixelRatio(parameters.devicePixelRatioF);
209 callbackObject.deliverInterlacingPass(myImage, variantParameters, state);
210 myImage.setDevicePixelRatio(1);
212 if (state == AsyncImageRenderCallback::InterlacingState::Intermediate) {
213 currentPass.switchToNextPass();
220static_assert(std::is_standard_layout_v<ChromaHueImageParameters>);
The namespace of this library.
int lightness() const const
bool canConvert() const const