Perceptual Color

chromahueimageparameters.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef CHROMAHUEIMAGEPARAMETERS_H
5#define CHROMAHUEIMAGEPARAMETERS_H
6
7#include <qglobal.h>
8#include <qmetatype.h>
9#include <qsharedpointer.h>
10#include <qvariant.h>
11
12namespace PerceptualColor
13{
14class AsyncImageRenderCallback;
15class RgbColorSpace;
16
17/** @internal
18 *
19 * @brief Parameters for an image of a chroma hue plane.
20 *
21 * For usage with @ref AsyncImageProvider.
22 *
23 * @warning The default constructor constructs an object with an empty
24 * @ref rgbColorSpace. Before using this object, you should initialize
25 * @ref rgbColorSpace.
26 *
27 * This is a cut through the gamut body. The cut is orthogonal to
28 * the L axis, so it shows the a‑b diagram (speaking in terms of
29 * LAB color model) respectively chroma‑hue diagram (speaking in terms
30 * of LCH color model). The center of the coordinate system is in
31 * the center of the image (floating point precision).
32 *
33 * Each pixel has the color that corresponds to the coordinate point <em>at
34 * the middle</em> of the pixel for in-gamut coordinate points, and
35 * a solid background color for out-of-gamut coordinate points.
36 *
37 * The <tt>QImage</tt> that is provided by this class has the
38 * size <tt>QSize(@ref ChromaHueImageParameters::imageSizePhysical,
39 * @ref ChromaHueImageParameters::imageSizePhysical)</tt>. There is an
40 * imaginary circle in the center of the <tt>QImage</tt> with a distance
41 * of @ref ChromaHueImageParameters::borderPhysical to the border of
42 * the <tt>QImage</tt>. All pixels within this imaginary circle, plus an
43 * overlap for safety, are calculated correctly. All other pixels
44 * have arbitrary values. Therefore, when you paint this
45 * image somewhere, you have to clip the painting to the imaginary circle.
46 * Thanks to the overlap, there will be no rendering artefacts, regardless
47 * of whether you render the circle with or without antialiasing.
48 *
49 * This type is declared as type to Qt’s type system via
50 * <tt>Q_DECLARE_METATYPE</tt>. Depending on your use case (for
51 * example if you want to use for <em>queued</em> signal-slot connections),
52 * you might consider calling <tt>qRegisterMetaType()</tt> for
53 * this type, once you have a QApplication object.
54 *
55 * @internal
56 *
57 * @todo Why does @ref ChromaHueImageParameters::render() not make everything
58 * outside the circle transparent? Because it would look ugly without
59 * antialiasing. And when we use antialiasing various times to cut of
60 * unwanted artefacts, half-opaque pixel become quarter-opaque and so on,
61 * so this would be ugly, too. However, we could use a single image to
62 * work on, and for each interlacing pass result, create a copy and
63 * apply the antialiased circle only to the copy. This would of course
64 * require more memory. On the other hand: When calling
65 * @ref AsyncImageRenderThread::deliverInterlacingPass() a signal will
66 * be emitted, which will create a copy anyway… */
67struct ChromaHueImageParameters final {
68public:
69 /** @brief The border size, measured in physical pixels. */
70 qreal borderPhysical = 0;
71 /** @brief The device pixel ratio as floating point. */
72 qreal devicePixelRatioF = 1;
73 /** @brief Image size, measured in physical pixels. */
74 int imageSizePhysical = 0;
75 /** @brief Lightness.
76 *
77 * This is the lightness (L) value in the LCH color model.
78 *
79 * Range: <tt>[0, 100]</tt> */
80 qreal lightness = 50;
81 /** @brief Pointer to @ref RgbColorSpace object
82 *
83 * @warning The default constructor constructs an object with an empty
84 * @ref rgbColorSpace. Before using this object, you must initialize
85 * @ref rgbColorSpace. */
87 [[nodiscard]] bool operator==(const ChromaHueImageParameters &other) const;
88 [[nodiscard]] bool operator!=(const ChromaHueImageParameters &other) const;
89
90 static void render(const QVariant &variantParameters, AsyncImageRenderCallback &callbackObject);
91};
92
93} // namespace PerceptualColor
94
95Q_DECLARE_METATYPE(PerceptualColor::ChromaHueImageParameters)
96
97#endif // CHROMAHUEIMAGEPARAMETERS_H
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.