KIconThemes

kiconeffect.cpp
1 /* vi: ts=8 sts=4 sw=4
2  *
3  * This file is part of the KDE project, module kdecore.
4  * Copyright (C) 2000 Geert Jansen <[email protected]>
5  * (C) 2007 Daniel M. Duley <[email protected]>
6  * with minor additions and based on ideas from
7  * Torsten Rahn <[email protected]>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License version 2 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #include "kiconeffect.h"
25 
26 #include <qplatformdefs.h>
27 #include <math.h>
28 
29 #include <QSysInfo>
30 #include <QDebug>
31 #include <QPixmap>
32 #include <QImage>
33 #include <QColor>
34 
35 #include <KColorScheme>
36 #include <kicontheme.h>
37 #include <KConfigGroup>
38 
39 class KIconEffectPrivate
40 {
41 public:
42  // http://en.cppreference.com/w/cpp/language/zero_initialization
43  KIconEffectPrivate()
44  : effect{{}}
45  , value{{}}
46  , color{{}}
47  , trans{{}}
48  , key{{}}
49  , color2{{}}
50  {
51  }
52 
53 public:
60 };
61 
63  : d(new KIconEffectPrivate)
64 {
65  init();
66 }
67 
68 KIconEffect::~KIconEffect()
69 {
70  delete d;
71 }
72 
74 {
75  KSharedConfig::Ptr config = KSharedConfig::openConfig();
76 
77  int i, j, effect = -1;
78  //FIXME: this really should be using KIconLoader::metaObject() to guarantee synchronization
79  // performance wise it's also practically guaranteed to be faster
80  QStringList groups;
81  groups += QStringLiteral("Desktop");
82  groups += QStringLiteral("Toolbar");
83  groups += QStringLiteral("MainToolbar");
84  groups += QStringLiteral("Small");
85  groups += QStringLiteral("Panel");
86  groups += QStringLiteral("Dialog");
87 
88  QStringList states;
89  states += QStringLiteral("Default");
90  states += QStringLiteral("Active");
91  states += QStringLiteral("Disabled");
92 
94  QString _togray(QStringLiteral("togray"));
95  QString _colorize(QStringLiteral("colorize"));
96  QString _desaturate(QStringLiteral("desaturate"));
97  QString _togamma(QStringLiteral("togamma"));
98  QString _none(QStringLiteral("none"));
99  QString _tomonochrome(QStringLiteral("tomonochrome"));
100 
101  for (it = groups.constBegin(), i = 0; it != groups.constEnd(); ++it, ++i) {
102  // Default effects
103  d->effect[i][0] = NoEffect;
104  d->effect[i][1] = ((i == 0) || (i == 4)) ? ToGamma : NoEffect;
105  d->effect[i][2] = ToGray;
106 
107  d->trans[i][0] = false;
108  d->trans[i][1] = false;
109  d->trans[i][2] = true;
110  d->value[i][0] = 1.0;
111  d->value[i][1] = ((i == 0) || (i == 4)) ? 0.7 : 1.0;
112  d->value[i][2] = 1.0;
113  d->color[i][0] = QColor(144, 128, 248);
114  d->color[i][1] = QColor(169, 156, 255);
115  d->color[i][2] = QColor(34, 202, 0);
116  d->color2[i][0] = QColor(0, 0, 0);
117  d->color2[i][1] = QColor(0, 0, 0);
118  d->color2[i][2] = QColor(0, 0, 0);
119 
120  KConfigGroup cg(config, *it + QStringLiteral("Icons"));
121  for (it2 = states.constBegin(), j = 0; it2 != states.constEnd(); ++it2, ++j) {
122  QString tmp = cg.readEntry(*it2 + QStringLiteral("Effect"), QString());
123  if (tmp == _togray) {
124  effect = ToGray;
125  } else if (tmp == _colorize) {
126  effect = Colorize;
127  } else if (tmp == _desaturate) {
128  effect = DeSaturate;
129  } else if (tmp == _togamma) {
130  effect = ToGamma;
131  } else if (tmp == _tomonochrome) {
132  effect = ToMonochrome;
133  } else if (tmp == _none) {
134  effect = NoEffect;
135  } else {
136  continue;
137  }
138  if (effect != -1) {
139  d->effect[i][j] = effect;
140  }
141  d->value[i][j] = cg.readEntry(*it2 + QStringLiteral("Value"), 0.0);
142  d->color[i][j] = cg.readEntry(*it2 + QStringLiteral("Color"), QColor());
143  d->color2[i][j] = cg.readEntry(*it2 + QStringLiteral("Color2"), QColor());
144  d->trans[i][j] = cg.readEntry(*it2 + QStringLiteral("SemiTransparent"), false);
145 
146  }
147  }
148 }
149 
150 bool KIconEffect::hasEffect(int group, int state) const
151 {
152  if (group < 0 || group >= KIconLoader::LastGroup ||
153  state < 0 || state >= KIconLoader::LastState) {
154  return false;
155  }
156 
157  return d->effect[group][state] != NoEffect;
158 }
159 
160 QString KIconEffect::fingerprint(int group, int state) const
161 {
162  if (group < 0 || group >= KIconLoader::LastGroup ||
163  state < 0 || state >= KIconLoader::LastState) {
164  return QString();
165  }
166 
167  QString cached = d->key[group][state];
168  if (cached.isEmpty()) {
169  QString tmp;
170  cached = tmp.setNum(d->effect[group][state]);
171  cached += QLatin1Char(':');
172  cached += tmp.setNum(d->value[group][state]);
173  cached += QLatin1Char(':');
174  cached += d->trans[group][state] ? QLatin1String("trans")
175  : QLatin1String("notrans");
176  if (d->effect[group][state] == Colorize || d->effect[group][state] == ToMonochrome) {
177  cached += QLatin1Char(':');
178  cached += d->color[group][state].name();
179  }
180  if (d->effect[group][state] == ToMonochrome) {
181  cached += QLatin1Char(':');
182  cached += d->color2[group][state].name();
183  }
184 
185  d->key[group][state] = cached;
186  }
187 
188  return cached;
189 }
190 
191 QImage KIconEffect::apply(const QImage &image, int group, int state) const
192 {
193  if (state >= KIconLoader::LastState) {
194  qWarning() << "Illegal icon state: " << state;
195  return image;
196  }
197  if (group >= KIconLoader::LastGroup) {
198  qWarning() << "Illegal icon group: " << group;
199  return image;
200  }
201  return apply(image, d->effect[group][state], d->value[group][state],
202  d->color[group][state], d->color2[group][state], d->trans[group][state]);
203 }
204 
205 QImage KIconEffect::apply(const QImage &image, int effect, float value,
206  const QColor &col, bool trans) const
207 {
208  return apply(image, effect, value, col,
209  KColorScheme(QPalette::Active, KColorScheme::View).background().color(), trans);
210 }
211 
212 QImage KIconEffect::apply(const QImage &img, int effect, float value,
213  const QColor &col, const QColor &col2, bool trans) const
214 {
215  QImage image = img;
216  if (effect >= LastEffect) {
217  qWarning() << "Illegal icon effect: " << effect;
218  return image;
219  }
220  if (value > 1.0) {
221  value = 1.0;
222  } else if (value < 0.0) {
223  value = 0.0;
224  }
225  switch (effect) {
226  case ToGray:
227  toGray(image, value);
228  break;
229  case DeSaturate:
230  deSaturate(image, value);
231  break;
232  case Colorize:
233  colorize(image, col, value);
234  break;
235  case ToGamma:
236  toGamma(image, value);
237  break;
238  case ToMonochrome:
239  toMonochrome(image, col, col2, value);
240  break;
241  }
242  if (trans == true) {
243  semiTransparent(image);
244  }
245  return image;
246 }
247 
248 QPixmap KIconEffect::apply(const QPixmap &pixmap, int group, int state) const
249 {
250  if (state >= KIconLoader::LastState) {
251  qWarning() << "Illegal icon state: " << state;
252  return pixmap;
253  }
254  if (group >= KIconLoader::LastGroup) {
255  qWarning() << "Illegal icon group: " << group;
256  return pixmap;
257  }
258  return apply(pixmap, d->effect[group][state], d->value[group][state],
259  d->color[group][state], d->color2[group][state], d->trans[group][state]);
260 }
261 
262 QPixmap KIconEffect::apply(const QPixmap &pixmap, int effect, float value,
263  const QColor &col, bool trans) const
264 {
265  return apply(pixmap, effect, value, col,
266  KColorScheme(QPalette::Active, KColorScheme::View).background().color(), trans);
267 }
268 
269 QPixmap KIconEffect::apply(const QPixmap &pixmap, int effect, float value,
270  const QColor &col, const QColor &col2, bool trans) const
271 {
272  QPixmap result;
273 
274  if (effect >= LastEffect) {
275  qWarning() << "Illegal icon effect: " << effect;
276  return result;
277  }
278 
279  if ((trans == true) && (effect == NoEffect)) {
280  result = pixmap;
281  semiTransparent(result);
282  } else if (effect != NoEffect) {
283  QImage tmpImg = pixmap.toImage();
284  tmpImg = apply(tmpImg, effect, value, col, col2, trans);
285  result = QPixmap::fromImage(tmpImg);
286  } else {
287  result = pixmap;
288  }
289 
290  return result;
291 }
292 
293 struct KIEImgEdit {
294  QImage &img;
295  QVector <QRgb> colors;
296  unsigned int *data;
297  unsigned int pixels;
298 
299  KIEImgEdit(QImage &_img): img(_img)
300  {
301  if (img.depth() > 8) {
302  //Code using data and pixels assumes that the pixels are stored
303  //in 32bit values and that the image is not premultiplied
304  if ((img.format() != QImage::Format_ARGB32) &&
305  (img.format() != QImage::Format_RGB32)) {
307  }
308  data = (unsigned int *)img.bits();
309  pixels = img.width() * img.height();
310  } else {
311  pixels = img.colorCount();
312  colors = img.colorTable();
313  data = (unsigned int *)colors.data();
314  }
315  }
316 
317  ~KIEImgEdit()
318  {
319  if (img.depth() <= 8) {
320  img.setColorTable(colors);
321  }
322  }
323 
324  KIEImgEdit(const KIEImgEdit &) = delete;
325  KIEImgEdit &operator=(const KIEImgEdit &) = delete;
326 };
327 
328 // Taken from KImageEffect. We don't want to link kdecore to kdeui! As long
329 // as this code is not too big, it doesn't seem much of a problem to me.
330 
331 void KIconEffect::toGray(QImage &img, float value)
332 {
333  if (value == 0.0) {
334  return;
335  }
336 
337  KIEImgEdit ii(img);
338  QRgb *data = ii.data;
339  QRgb *end = data + ii.pixels;
340 
341  unsigned char gray;
342  if (value == 1.0) {
343  while (data != end) {
344  gray = qGray(*data);
345  *data = qRgba(gray, gray, gray, qAlpha(*data));
346  ++data;
347  }
348  } else {
349  unsigned char val = (unsigned char)(255.0 * value);
350  while (data != end) {
351  gray = qGray(*data);
352  *data = qRgba((val * gray + (0xFF - val) * qRed(*data)) >> 8,
353  (val * gray + (0xFF - val) * qGreen(*data)) >> 8,
354  (val * gray + (0xFF - val) * qBlue(*data)) >> 8,
355  qAlpha(*data));
356  ++data;
357  }
358  }
359 }
360 
361 void KIconEffect::colorize(QImage &img, const QColor &col, float value)
362 {
363  if (value == 0.0) {
364  return;
365  }
366 
367  KIEImgEdit ii(img);
368  QRgb *data = ii.data;
369  QRgb *end = data + ii.pixels;
370 
371  float rcol = col.red(), gcol = col.green(), bcol = col.blue();
372  unsigned char red, green, blue, gray;
373  unsigned char val = (unsigned char)(255.0 * value);
374  while (data != end) {
375  gray = qGray(*data);
376  if (gray < 128) {
377  red = static_cast<unsigned char>(rcol / 128 * gray);
378  green = static_cast<unsigned char>(gcol / 128 * gray);
379  blue = static_cast<unsigned char>(bcol / 128 * gray);
380  } else if (gray > 128) {
381  red = static_cast<unsigned char>((gray - 128) * (2 - rcol / 128) + rcol - 1);
382  green = static_cast<unsigned char>((gray - 128) * (2 - gcol / 128) + gcol - 1);
383  blue = static_cast<unsigned char>((gray - 128) * (2 - bcol / 128) + bcol - 1);
384  } else {
385  red = static_cast<unsigned char>(rcol);
386  green = static_cast<unsigned char>(gcol);
387  blue = static_cast<unsigned char>(bcol);
388  }
389 
390  *data = qRgba((val * red + (0xFF - val) * qRed(*data)) >> 8,
391  (val * green + (0xFF - val) * qGreen(*data)) >> 8,
392  (val * blue + (0xFF - val) * qBlue(*data)) >> 8,
393  qAlpha(*data));
394  ++data;
395  }
396 }
397 
398 void KIconEffect::toMonochrome(QImage &img, const QColor &black,
399  const QColor &white, float value)
400 {
401  if (value == 0.0) {
402  return;
403  }
404 
405  KIEImgEdit ii(img);
406  QRgb *data = ii.data;
407  QRgb *end = data + ii.pixels;
408 
409  // Step 1: determine the average brightness
410  double values = 0.0, sum = 0.0;
411  bool grayscale = true;
412  while (data != end) {
413  sum += qGray(*data) * qAlpha(*data) + 255 * (255 - qAlpha(*data));
414  values += 255;
415  if ((qRed(*data) != qGreen(*data)) || (qGreen(*data) != qBlue(*data))) {
416  grayscale = false;
417  }
418  ++data;
419  }
420  double medium = sum / values;
421 
422  // Step 2: Modify the image
423  unsigned char val = (unsigned char)(255.0 * value);
424  int rw = white.red(), gw = white.green(), bw = white.blue();
425  int rb = black.red(), gb = black.green(), bb = black.blue();
426  data = ii.data;
427 
428  if (grayscale) {
429  while (data != end) {
430  if (qRed(*data) <= medium)
431  *data = qRgba((val * rb + (0xFF - val) * qRed(*data)) >> 8,
432  (val * gb + (0xFF - val) * qGreen(*data)) >> 8,
433  (val * bb + (0xFF - val) * qBlue(*data)) >> 8,
434  qAlpha(*data));
435  else
436  *data = qRgba((val * rw + (0xFF - val) * qRed(*data)) >> 8,
437  (val * gw + (0xFF - val) * qGreen(*data)) >> 8,
438  (val * bw + (0xFF - val) * qBlue(*data)) >> 8,
439  qAlpha(*data));
440  ++data;
441  }
442  } else {
443  while (data != end) {
444  if (qGray(*data) <= medium)
445  *data = qRgba((val * rb + (0xFF - val) * qRed(*data)) >> 8,
446  (val * gb + (0xFF - val) * qGreen(*data)) >> 8,
447  (val * bb + (0xFF - val) * qBlue(*data)) >> 8,
448  qAlpha(*data));
449  else
450  *data = qRgba((val * rw + (0xFF - val) * qRed(*data)) >> 8,
451  (val * gw + (0xFF - val) * qGreen(*data)) >> 8,
452  (val * bw + (0xFF - val) * qBlue(*data)) >> 8,
453  qAlpha(*data));
454  ++data;
455  }
456  }
457 }
458 
459 void KIconEffect::deSaturate(QImage &img, float value)
460 {
461  if (value == 0.0) {
462  return;
463  }
464 
465  KIEImgEdit ii(img);
466  QRgb *data = ii.data;
467  QRgb *end = data + ii.pixels;
468 
469  QColor color;
470  int h, s, v;
471  while (data != end) {
472  color.setRgb(*data);
473  color.getHsv(&h, &s, &v);
474  color.setHsv(h, (int)(s * (1.0 - value) + 0.5), v);
475  *data = qRgba(color.red(), color.green(), color.blue(),
476  qAlpha(*data));
477  ++data;
478  }
479 }
480 
481 void KIconEffect::toGamma(QImage &img, float value)
482 {
483  KIEImgEdit ii(img);
484  QRgb *data = ii.data;
485  QRgb *end = data + ii.pixels;
486 
487  float gamma = 1 / (2 * value + 0.5);
488  while (data != end) {
489  *data = qRgba(static_cast<unsigned char>
490  (pow(static_cast<float>(qRed(*data)) / 255, gamma) * 255),
491  static_cast<unsigned char>
492  (pow(static_cast<float>(qGreen(*data)) / 255, gamma) * 255),
493  static_cast<unsigned char>
494  (pow(static_cast<float>(qBlue(*data)) / 255, gamma) * 255),
495  qAlpha(*data));
496  ++data;
497  }
498 }
499 
501 {
502  if (img.depth() == 32) {
505  }
506  int width = img.width();
507  int height = img.height();
508 
509  unsigned char *line;
510  for (int y = 0; y < height; ++y) {
512  line = img.scanLine(y);
513  } else {
514  line = img.scanLine(y) + 3;
515  }
516  for (int x = 0; x < width; ++x) {
517  *line >>= 1;
518  line += 4;
519  }
520  }
521  } else if (img.depth() == 8) {
522  // not running on 8 bit, we can safely install a new colorTable
523  QVector<QRgb> colorTable = img.colorTable();
524  for (int i = 0; i < colorTable.size(); ++i) {
525  colorTable[i] = (colorTable[i] & 0x00ffffff) | ((colorTable[i] & 0xfe000000) >> 1);
526  }
527  img.setColorTable(colorTable);
528  } else {
529  // Insert transparent pixel into the clut.
530  int transColor = -1;
531 
532  // search for a color that is already transparent
533  for (int x = 0; x < img.colorCount(); ++x) {
534  // try to find already transparent pixel
535  if (qAlpha(img.color(x)) < 127) {
536  transColor = x;
537  break;
538  }
539  }
540 
541  // FIXME: image must have transparency
542  if (transColor < 0 || transColor >= img.colorCount()) {
543  return;
544  }
545 
546  img.setColor(transColor, 0);
547  unsigned char *line;
548  if (img.depth() == 8) {
549  for (int y = 0; y < img.height(); ++y) {
550  line = img.scanLine(y);
551  for (int x = (y % 2); x < img.width(); x += 2) {
552  line[x] = transColor;
553  }
554  }
555  } else {
556  const bool setOn = (transColor != 0);
557  if (img.format() == QImage::Format_MonoLSB) {
558  for (int y = 0; y < img.height(); ++y) {
559  line = img.scanLine(y);
560  for (int x = (y % 2); x < img.width(); x += 2) {
561  if (!setOn) {
562  *(line + (x >> 3)) &= ~(1 << (x & 7));
563  } else {
564  *(line + (x >> 3)) |= (1 << (x & 7));
565  }
566  }
567  }
568  } else {
569  for (int y = 0; y < img.height(); ++y) {
570  line = img.scanLine(y);
571  for (int x = (y % 2); x < img.width(); x += 2) {
572  if (!setOn) {
573  *(line + (x >> 3)) &= ~(1 << (7 - (x & 7)));
574  } else {
575  *(line + (x >> 3)) |= (1 << (7 - (x & 7)));
576  }
577  }
578  }
579  }
580  }
581  }
582 }
583 
585 {
586  QImage img = pix.toImage();
587  semiTransparent(img);
588  pix = QPixmap::fromImage(img);
589 }
590 
592 {
593  int w = src.width();
594  int h = src.height();
595 
596  QImage dst(w * 2, h * 2, src.format());
597 
598  if (src.depth() == 1) {
599  qWarning() << "image depth 1 not supported";
600  return QImage();
601  }
602 
603  int x, y;
604  if (src.depth() == 32) {
605  QRgb *l1, *l2;
606  for (y = 0; y < h; ++y) {
607  l1 = (QRgb *)src.scanLine(y);
608  l2 = (QRgb *)dst.scanLine(y * 2);
609  for (x = 0; x < w; ++x) {
610  l2[x * 2] = l2[x * 2 + 1] = l1[x];
611  }
612  memcpy(dst.scanLine(y * 2 + 1), l2, dst.bytesPerLine());
613  }
614  } else {
615  for (x = 0; x < src.colorCount(); ++x) {
616  dst.setColor(x, src.color(x));
617  }
618 
619  const unsigned char *l1;
620  unsigned char *l2;
621  for (y = 0; y < h; ++y) {
622  l1 = src.scanLine(y);
623  l2 = dst.scanLine(y * 2);
624  for (x = 0; x < w; ++x) {
625  l2[x * 2] = l1[x];
626  l2[x * 2 + 1] = l1[x];
627  }
628  memcpy(dst.scanLine(y * 2 + 1), l2, dst.bytesPerLine());
629  }
630  }
631  return dst;
632 }
633 
635 {
636  if (src.depth() != overlay.depth()) {
637  qWarning() << "Image depth src (" << src.depth() << ") != overlay " << "(" << overlay.depth() << ")!";
638  return;
639  }
640  if (src.size() != overlay.size()) {
641  qWarning() << "Image size src != overlay";
642  return;
643  }
646  }
647 
648  if (overlay.format() == QImage::Format_RGB32) {
649  qWarning() << "Overlay doesn't have alpha buffer!";
650  return;
651  } else if (overlay.format() == QImage::Format_ARGB32_Premultiplied) {
652  overlay = overlay.convertToFormat(QImage::Format_ARGB32);
653  }
654 
655  int i, j;
656 
657  // We don't do 1 bpp
658 
659  if (src.depth() == 1) {
660  qWarning() << "1bpp not supported!";
661  return;
662  }
663 
664  // Overlay at 8 bpp doesn't use alpha blending
665 
666  if (src.depth() == 8) {
667  if (src.colorCount() + overlay.colorCount() > 255) {
668  qWarning() << "Too many colors in src + overlay!";
669  return;
670  }
671 
672  // Find transparent pixel in overlay
673  int trans;
674  for (trans = 0; trans < overlay.colorCount(); trans++) {
675  if (qAlpha(overlay.color(trans)) == 0) {
676  qWarning() << "transparent pixel found at " << trans;
677  break;
678  }
679  }
680  if (trans == overlay.colorCount()) {
681  qWarning() << "transparent pixel not found!";
682  return;
683  }
684 
685  // Merge color tables
686  int nc = src.colorCount();
687  src.setColorCount(nc + overlay.colorCount());
688  for (i = 0; i < overlay.colorCount(); ++i) {
689  src.setColor(nc + i, overlay.color(i));
690  }
691 
692  // Overwrite nontransparent pixels.
693  unsigned char *oline, *sline;
694  for (i = 0; i < src.height(); ++i) {
695  oline = overlay.scanLine(i);
696  sline = src.scanLine(i);
697  for (j = 0; j < src.width(); ++j) {
698  if (oline[j] != trans) {
699  sline[j] = oline[j] + nc;
700  }
701  }
702  }
703  }
704 
705  // Overlay at 32 bpp does use alpha blending
706 
707  if (src.depth() == 32) {
708  QRgb *oline, *sline;
709  int r1, g1, b1, a1;
710  int r2, g2, b2, a2;
711 
712  for (i = 0; i < src.height(); ++i) {
713  oline = (QRgb *)overlay.scanLine(i);
714  sline = (QRgb *)src.scanLine(i);
715 
716  for (j = 0; j < src.width(); ++j) {
717  r1 = qRed(oline[j]);
718  g1 = qGreen(oline[j]);
719  b1 = qBlue(oline[j]);
720  a1 = qAlpha(oline[j]);
721 
722  r2 = qRed(sline[j]);
723  g2 = qGreen(sline[j]);
724  b2 = qBlue(sline[j]);
725  a2 = qAlpha(sline[j]);
726 
727  r2 = (a1 * r1 + (0xff - a1) * r2) >> 8;
728  g2 = (a1 * g1 + (0xff - a1) * g2) >> 8;
729  b2 = (a1 * b1 + (0xff - a1) * b2) >> 8;
730  a2 = qMax(a1, a2);
731 
732  sline[j] = qRgba(r2, g2, b2, a2);
733  }
734  }
735  }
736 }
737 
uchar * scanLine(int i)
QImage convertToFormat(QImage::Format format, Qt::ImageConversionFlags flags) const &const
static void semiTransparent(QImage &image)
Renders an image semi-transparent.
int depth() const const
int colorCount() const const
void setColorCount(int colorCount)
QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags)
QRgb color(int i) const const
void setRgb(int r, int g, int b, int a)
static void toMonochrome(QImage &image, const QColor &black, const QColor &white, float value)
Produces a monochrome icon with a given foreground and background color.
void getHsv(int *h, int *s, int *v, int *a) const const
void setColor(int index, QRgb colorValue)
static void overlay(QImage &src, QImage &overlay)
Overlays an image with an other image.
QVector< V > values(const QMultiHash< K, V > &c)
T * data()
KIconEffect()
Create a new KIconEffect.
Definition: kiconeffect.cpp:62
static void colorize(QImage &image, const QColor &col, float value)
Colorizes an image with a specific color.
static void deSaturate(QImage &image, float value)
Desaturates an image.
int red() const const
int width() const const
bool isEmpty() const const
void init()
Rereads configuration.
Definition: kiconeffect.cpp:73
static void toGamma(QImage &image, float value)
Changes the gamma value of an image.
int green() const const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
int blue() const const
Last state (last constant)
Definition: kiconloader.h:180
QString & setNum(short n, int base)
QString fingerprint(int group, int state) const
Returns a fingerprint for the effect by encoding the given group and state into a QString...
bool hasEffect(int group, int state) const
Tests whether an effect has been configured for the given icon group.
typedef ConstIterator
void setColorTable(const QVector< QRgb > colors)
static void toGray(QImage &image, float value)
Tints an image gray.
QSize size() const const
void setHsv(int h, int s, int v, int a)
uchar * bits()
int height() const const
QImage apply(const QImage &src, int group, int state) const
Applies an effect to an image.
QImage toImage() const const
QList::const_iterator constEnd() const const
QList::const_iterator constBegin() const const
int size() const const
QImage::Format format() const const
T readEntry(const QString &key, const T &aDefault) const
QImage doublePixels(const QImage &src) const
Returns an image twice as large, consisting of 2x2 pixels.
QVector< QRgb > colorTable() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 4 2020 22:40:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.