34#include <config-use-surface-color-management-api.h>
35#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
63#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
76#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
144 using namespace std::placeholders;
145 std::function<
void (qreal)> callback(
156 d->
hueWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
161 d->
valueWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
167#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
190 QVBoxLayout *layout =
new QVBoxLayout(
this);
195 layout->addSpacing(16);
209 h = qBound(0.0, h, 1.0);
218 h = qBound(0.0, h, 1.0);
219 s = qBound(0.0, s, 1.0);
220 v = qBound(0.0,
v, 1.0);
269 if (rangeCoeff < r || rangeCoeff < g || rangeCoeff < b) {
270 rangeCoeff = std::max({r, g, b}) * 1.10f;
281 r = qBound(0.0f, r, 1.0f);
282 g = qBound(0.0f, g, 1.0f);
283 b = qBound(0.0f, b, 1.0f);
286 float denormHue, saturation,
value;
292 setHSV(denormHue / 360.0, saturation,
value,
false);
303 static inline void getRGB(qreal ,
float xPortionCoeff,
float ,
304 int x,
int ,
float *r,
float *g,
float *b) {
306 HSVToRGB(xPortionCoeff * x * 360.0f, 1.0, 1.0, r, g, b);
311 static inline void getRGB(qreal hue,
float xPortionCoeff,
float yPortionCoeff,
312 int x,
int y,
float *r,
float *g,
float *b) {
314 HSVToRGB(hue * 360.0, xPortionCoeff * x, 1.0 - yPortionCoeff * y, r, g, b);
319template<
class FillPolicy>
322 if (!isEnabled() || size.isEmpty())
return;
325 const float xPortionCoeff = 1.0 / image.
width();
326 const float yPortionCoeff = 1.0 / image.
height();
332 half *pixelPtr = image.
data();
334 for (
int y = 0; y < image.
height(); y++) {
335 for (
int x = 0; x < image.
width(); x++) {
336 Imf::Rgba &pxl =
reinterpret_cast<Imf::Rgba &
>(*pixelPtr);
339 FillPolicy::getRGB(
d->
hue, xPortionCoeff, yPortionCoeff, x, y,
342 pxl.r = r * rangeCoeff;
343 pxl.g = g * rangeCoeff;
344 pxl.b = b * rangeCoeff;
357 float *devicePtr =
reinterpret_cast<float*
>(device->
data());
359 for (
int y = 0; y < image.
height(); y++) {
360 for (
int x = 0; x < image.
width(); x++) {
361 FillPolicy::getRGB(
d->
hue, xPortionCoeff, yPortionCoeff, x, y,
362 devicePtr, devicePtr + 1, devicePtr + 2);
364 devicePtr[0] *= rangeCoeff;
365 devicePtr[1] *= rangeCoeff;
366 devicePtr[2] *= rangeCoeff;
400 const int maxSize = 256;
402 newSize.rwidth() = qMin(maxSize, newSize.width());
403 newSize.rheight() = qMin(maxSize, newSize.height());
405 uploadPaletteData<FillSVPolicy>(
d->
valueWidget, newSize);
410 const qreal newHue = pos.x();
419 const qreal newSaturation = pos.x();
420 const qreal newValue = 1.0 - pos.y();
423 !qFuzzyCompare(newValue,
d->
value)) {
442 float denormHue =
d->
hue * 360.0;
448 const qreal transformCoeff = oldRange / newRange;
450 r = qBound(0.0, r * transformCoeff, 1.0);
451 g = qBound(0.0, g * transformCoeff, 1.0);
452 b = qBound(0.0, b * transformCoeff, 1.0);
458 setHSV(denormHue / 360.0, saturation,
value,
false);
498 qWarning() <<
"WARNING: KisSmallColorWidget::slotDisplayConfigurationChanged(): output color space is "
499 "not a PQ space, the meaning of the range slider may be wrong!";
557 QWidget::resizeEvent(event);
float value(const T *src, size_t ch)
void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
void getRGB(TReal &r, TReal &g, TReal &b, TReal hue)
const KoColorSpace * paintingColorSpace() const
KisDisplayConfig displayConfig() const
static KisDisplayColorConverter * dumbConverterInstance()
bool canSkipDisplayConversion(const KoColorSpace *cs) const
void applyDisplayFilteringF32(KisFixedPaintDeviceSP device, const KoColorSpace *dstColorSpace) const
const KoColorProfile * profile
void reallocateBufferWithoutInitialization()
void setRect(const QRect &rc)
quint32 pixelSize() const
static KisOpenGLModeProber * instance()
const KoColorProfile * rootSurfaceColorProfile() const
const KoColorProfile * rootSurfaceProfile() const
void sigRootSurfaceProfileChanged(const KoColorProfile *profile) const
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void setExponentRatio(qreal newExponentRatio)
Set the exponent used by a power function to modify the values as a function of the horizontal positi...
void setValue(int newValue)
void setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep=true)
Set the minimum and the maximum values of the range, computing a new "fast slider step" based on the ...
void setPageStep(int newPageStep)
Does nothing currently.
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual void normalisedChannelsValue(const quint8 *pixel, QVector< float > &channels) const =0
virtual void fromNormalisedChannelsValue(quint8 *pixel, const QVector< float > &values) const =0
virtual const KoColorProfile * profile() const =0
void convertTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
virtual std::optional< double > hdrReferenceWhite() const =0
hdrReferenceWhite HDR reference white is only available for Perceptual Quantizer profiles that save t...
virtual TransferCharacteristics getTransferCharacteristics() const
getTransferCharacteristics This function should be subclassed at some point so we can get the value f...
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()
const KoColorProfile * p709SRGBProfile() const
const KoColorProfile * p2020G10Profile() const