19GammaDisp::GammaDisp(
QWidget *parent,
int *brightness,
int *contrast,
int *gamma,
int maxValue)
21, m_brightness(brightness)
24, m_gammaColor(
QColor::fromRgb(0,0,0))
28QSize GammaDisp::minimumSizeHint()
const
33QSize GammaDisp::sizeHint()
const
38void GammaDisp::setColor(
const QColor &color)
58 const int xResolution = 100;
59 double max =
static_cast<double>(m_maxValue);
60 double xscale =
static_cast<double>(size().width() - 1) /
static_cast<double>(xResolution);
61 double yscale =
static_cast<double>(size().height() - 1) / max;
63 painter.setPen(m_gammaColor);
65 double gamma = 100.0 / *m_gamma;
66 double contrast = (200.0 / (100.0 - *m_contrast)) - 1;
67 double halfMax = max / 2.0;
68 double brightness = (*m_brightness / halfMax) * max;
74 xPrevious = (contrast * (xPrevious - halfMax)) + halfMax;
76 xPrevious += brightness + 0.5;
78 if (xPrevious > max) {
85 for (
int i = 0; i < xResolution - 1; i++) {
86 xNext = std::pow(
static_cast<double>(i+1) / xResolution, gamma) * max;
88 xNext = (contrast * (xNext - halfMax)) + halfMax;
90 xNext += brightness + 0.5;
101 p1.
setY(size().height() - 1 - (xPrevious * yscale));
103 p2.
setX((i + 1)*xscale);
104 p2.
setY(size().height() - 1 - (xNext * yscale));
106 painter.drawLine(p1, p2);
113#include "moc_gammadisp.cpp"
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:01 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.