QImage KIconEffect::apply(const QImage &img, int effect, float value, const QColor &col, const QColor &col2, bool trans) const { QImage image = img; if (effect >= LastEffect) { qWarning() << "Illegal icon effect: " << effect; return image; } if (value > 1.0) { value = 1.0; } else if (value < 0.0) { value = 0.0; } switch (effect) { case ToGray: toGray(image, value); break; case DeSaturate: deSaturate(image, value); break; case Colorize: colorize(image, col, value); break; case ToGamma: toGamma(image, value); break; case ToMonochrome: toMonochrome(image, col, col2, value); break; } if (trans == true) { semiTransparent(image); } return image; }
const QImage& ImageTransformer:: gammaConvert(double gamma) { int width = _DataHandled.width(); int height = _DataHandled.height(); int depth = _DataHandled.depth(); if(depth == 32) { for(int i=0;i<width;++i) { for(int j=0;j<height;++j) { QColor pixTmp = _DataHandled.pixel(i,j); toGamma(pixTmp,gamma); _DataHandled.setPixel(i,j,pixTmp.rgb()); } } } return _DataHandled; }