Perceptual Color
5#include "helperimage.h"
7#include "asyncimagerendercallback.h"
8#include "cielchd50values.h"
9#include "helperconstants.h"
10#include "helpermath.h"
11#include "helperqttypes.h"
12#include "interlacingpass.h"
13#include "rgbcolorspace.h"
18#include <qnamespace.h>
21#include <qsharedpointer.h>
45 int width = image.
width();
46 int height = image.
height();
47 for (
int y = 0; y < height; ++y) {
48 for (
int x = 0; x < width; ++x) {
60 bool hasTransparentNeighbor =
false;
62 for (
int dy = -1; dy <= 1; ++dy) {
63 for (
int dx = -1; dx <= 1; ++dx) {
64 if (dx == 0 && dy == 0) {
67 const auto xOutOfRange =
68 ((x + dx < 0) || (x + dx >= image.
width()));
69 const auto yOutOfRange =
70 ((y + dy < 0) || (y + dy >= image.
height()));
71 if (xOutOfRange || yOutOfRange) {
75 const auto myPixelColor =
77 if (myPixelColor.alpha() == 0) {
78 hasTransparentNeighbor =
true;
80 if (!coordinates.
contains(myNeighbor)) {
82 coordinates.
append(myNeighbor);
87 if (hasTransparentNeighbor) {
88 const auto gamutPixel =
QPoint(x, y);
89 if (!coordinates.
contains(gamutPixel)) {
91 coordinates.
append(gamutPixel);
130 for (
const auto myValue : antiAliasCoordinates) {
138 constexpr int sideLength = 16;
139 constexpr int totalDataPoints = sideLength * sideLength;
140 opaqueColors.
clear();
141 opaqueColors.
reserve(totalDataPoints);
142 constexpr double stepWidth = 1.0 / sideLength;
143 double x = myValue.x() - 0.5 + stepWidth / 2;
144 double y = myValue.y() - 0.5 + stepWidth / 2;
145 for (
int i = 0; i < sideLength; ++i) {
146 for (
int j = 0; j < sideLength; ++j) {
147 const QRgb tempColor = colorFunction(x + i * stepWidth,
149 if (qAlpha(tempColor) != 0) {
150 opaqueColors.
append(tempColor);
154 if (opaqueColors.
count() > 0) {
155 const QColorFloatType countF =
156 static_cast<QColorFloatType
>(opaqueColors.
count());
158 if (newPixel.
alpha() == 0) {
162 QColorFloatType r = 0;
163 QColorFloatType g = 0;
164 QColorFloatType b = 0;
165 for (
const QColor &myColor : opaqueColors) {
167 g += myColor.greenF();
168 b += myColor.blueF();
175 newPixel.
setAlphaF(countF / totalDataPoints);
The namespace of this library.
void doAntialias(QImage &image, const QList< QPoint > &antiAliasCoordinates, const std::function< QRgb(const double x, const double y)> &colorFunction)
Calculates anti-alias for gamut diagrams.
QList< QPoint > findBoundary(const QImage &image)
Find boundaries between fully opaque and fully transparent pixels.
QColor fromRgbF(float r, float g, float b, float a)
void setAlphaF(float alpha)
QColor pixelColor(const QPoint &position) const const
void setPixelColor(const QPoint &position, const QColor &color)
void append(QList< T > &&value)
bool contains(const AT &value) const const
qsizetype count() const const
void reserve(qsizetype size)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 12:03:13 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.