ImageColors

Search for usage in LXR

#include <imagecolors.h>

Inheritance diagram for ImageColors:

Properties

QColor average
 
QColor background
 
QColor closestToBlack
 
QColor closestToWhite
 
QColor dominant
 
QColor dominantContrast
 
QColor fallbackAverage
 
QColor fallbackBackground
 
QColor fallbackDominant
 
QColor fallbackDominantContrasting
 
QColor fallbackForeground
 
QColor fallbackHighlight
 
QList< PaletteSwatch > fallbackPalette
 
ColorUtils::Brightness fallbackPaletteBrightness
 
QColor foreground
 
QColor highlight
 
QList< PaletteSwatch > palette
 
ColorUtils::Brightness paletteBrightness
 
QML_ELEMENTQVariant source
 
- Properties inherited from QObject
 objectName
 

Signals

void fallbackAverageChanged ()
 
void fallbackBackgroundChanged ()
 
void fallbackDominantChanged ()
 
void fallbackDominantContrastingChanged ()
 
void fallbackForegroundChanged ()
 
void fallbackHighlightChanged ()
 
void fallbackPaletteBrightnessChanged ()
 
void fallbackPaletteChanged ()
 
void paletteChanged ()
 
void sourceChanged ()
 

Public Member Functions

 ImageColors (QObject *parent=nullptr)
 
QColor average () const
 
QColor background () const
 
QColor closestToBlack () const
 
QColor closestToWhite () const
 
QColor dominant () const
 
QColor dominantContrast () const
 
QColor foreground () const
 
QColor highlight () const
 
QList< PaletteSwatch > palette () const
 
ColorUtils::Brightness paletteBrightness () const
 
void setSource (const QVariant &source)
 
void setSourceImage (const QImage &image)
 
void setSourceItem (QQuickItem *source)
 
QVariant source () const
 
QImage sourceImage () const
 
QQuickItemsourceItem () const
 
Q_INVOKABLE void update ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Extracts the dominant colors from an element or an image and exports it to a color palette.

Definition at line 76 of file imagecolors.h.

Property Documentation

◆ average

QColor ImageColors::average
read

The average color of the source image.

Definition at line 121 of file imagecolors.h.

◆ background

QColor ImageColors::background
read

A color suitable for rendering a background behind the source image.

On dark items, this will be the color closest to black in the image if it's dark enough, or a dark gray otherwise. On light items, this will be the color closest to white in the image if it's light enough, or a bright gray otherwise.

Definition at line 168 of file imagecolors.h.

◆ closestToBlack

QColor ImageColors::closestToBlack
read

The darkest color of the source image.

Definition at line 178 of file imagecolors.h.

◆ closestToWhite

QColor ImageColors::closestToWhite
read

The lightest color of the source image.

Definition at line 173 of file imagecolors.h.

◆ dominant

QColor ImageColors::dominant
read

The dominant color of the source image.

The dominant color of the image is the color of the largest cluster in the image.

See also
https://en.wikipedia.org/wiki/K-means_clustering

Definition at line 131 of file imagecolors.h.

◆ dominantContrast

QColor ImageColors::dominantContrast
read

Suggested "contrasting" color to the dominant one.

It's the color in the palette nearest to the negative of the dominant

Definition at line 136 of file imagecolors.h.

◆ fallbackAverage

QColor ImageColors::fallbackAverage

The value to return when average is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 196 of file imagecolors.h.

◆ fallbackBackground

QColor ImageColors::fallbackBackground

The value to return when background is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 226 of file imagecolors.h.

◆ fallbackDominant

QColor ImageColors::fallbackDominant

The value to return when dominant is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 202 of file imagecolors.h.

◆ fallbackDominantContrasting

QColor ImageColors::fallbackDominantContrasting

The value to return when dominantContrasting is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 208 of file imagecolors.h.

◆ fallbackForeground

QColor ImageColors::fallbackForeground

The value to return when foreground is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 220 of file imagecolors.h.

◆ fallbackHighlight

QColor ImageColors::fallbackHighlight

The value to return when highlight is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 214 of file imagecolors.h.

◆ fallbackPalette

QList<PaletteSwatch> ImageColors::fallbackPalette

The value to return when palette is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 184 of file imagecolors.h.

◆ fallbackPaletteBrightness

ColorUtils::Brightness ImageColors::fallbackPaletteBrightness

The value to return when paletteBrightness is not available, e.g.

when ImageColors is still computing it or the source is invalid.

Definition at line 190 of file imagecolors.h.

◆ foreground

QColor ImageColors::foreground
read

A color suitable for rendering text and other foreground over the source image.

On dark items, this will be the color closest to white in the image if it's light enough, or a bright gray otherwise. On light items, this will be the color closest to black in the image if it's dark enough, or a dark gray otherwise.

Definition at line 157 of file imagecolors.h.

◆ highlight

QColor ImageColors::highlight
read

An accent color extracted from the source image.

The accent color is the color cluster with the highest CIELAB chroma in the source image.

See also
https://en.wikipedia.org/wiki/Colorfulness#Chroma

Definition at line 146 of file imagecolors.h.

◆ palette

QList<PaletteSwatch> ImageColors::palette
read

A list of colors and related information about then.

Each list item has the following properties:

  • color: The color of the list item.
  • ratio: How dominant the color is in the source image.
  • contrastingColor: The color from the source image that's closest to the inverse of color.

The list is sorted by ratio; the first element is the most dominant color in the source image and the last element is the least dominant color of the image.

Note
K-means clustering is used to extract these colors; see https://en.wikipedia.org/wiki/K-means_clustering.

Definition at line 108 of file imagecolors.h.

◆ paletteBrightness

ColorUtils::Brightness ImageColors::paletteBrightness
read

Information whether the palette is towards a light or dark color scheme, possible values are:

Definition at line 116 of file imagecolors.h.

◆ source

QML_ELEMENTQVariant ImageColors::source
readwrite

The source from which colors should be extracted from.

source can be one of the following:

Note that an Item's color palette will only be extracted once unless you call update(), regardless of how the item hanges.

Definition at line 92 of file imagecolors.h.

Constructor & Destructor Documentation

◆ ImageColors()

ImageColors::ImageColors ( QObject * parent = nullptr)
explicit

Definition at line 71 of file imagecolors.cpp.

◆ ~ImageColors()

ImageColors::~ImageColors ( )
override

Definition at line 76 of file imagecolors.cpp.

Member Function Documentation

◆ average()

QColor ImageColors::average ( ) const

Definition at line 586 of file imagecolors.cpp.

◆ background()

QColor ImageColors::background ( ) const

Definition at line 633 of file imagecolors.cpp.

◆ closestToBlack()

QColor ImageColors::closestToBlack ( ) const

Definition at line 673 of file imagecolors.cpp.

◆ closestToWhite()

QColor ImageColors::closestToWhite ( ) const

Definition at line 661 of file imagecolors.cpp.

◆ dominant()

QColor ImageColors::dominant ( ) const

Definition at line 595 of file imagecolors.cpp.

◆ dominantContrast()

QColor ImageColors::dominantContrast ( ) const

Definition at line 604 of file imagecolors.cpp.

◆ foreground()

QColor ImageColors::foreground ( ) const

Definition at line 613 of file imagecolors.cpp.

◆ highlight()

QColor ImageColors::highlight ( ) const

Definition at line 652 of file imagecolors.cpp.

◆ palette()

QList< PaletteSwatch > ImageColors::palette ( ) const

Definition at line 569 of file imagecolors.cpp.

◆ paletteBrightness()

ColorUtils::Brightness ImageColors::paletteBrightness ( ) const

Definition at line 577 of file imagecolors.cpp.

◆ setSource()

void ImageColors::setSource ( const QVariant & source)

Definition at line 80 of file imagecolors.cpp.

◆ setSourceImage()

void ImageColors::setSourceImage ( const QImage & image)

Definition at line 131 of file imagecolors.cpp.

◆ setSourceItem()

void ImageColors::setSourceItem ( QQuickItem * source)

Definition at line 155 of file imagecolors.cpp.

◆ source()

QVariant ImageColors::source ( ) const

Definition at line 126 of file imagecolors.cpp.

◆ sourceImage()

QImage ImageColors::sourceImage ( ) const

Definition at line 150 of file imagecolors.cpp.

◆ sourceItem()

QQuickItem * ImageColors::sourceItem ( ) const

Definition at line 187 of file imagecolors.cpp.

◆ update()

void ImageColors::update ( )

Definition at line 192 of file imagecolors.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:51:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.