kimageeffect.h
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
(C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Dirk Mueller <mueller@kde.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// $Id: kimageeffect.h 399215 2005-03-20 14:33:45Z mueller $
#ifndef __KIMAGE_EFFECT_H
#define __KIMAGE_EFFECT_H
#include <kdelibs_export.h>
class QImage;
class QSize;
class QColor;
class QPoint;
class QRect;
class KDEFX_EXPORT KImageEffect
{
public:
enum GradientType { VerticalGradient,
HorizontalGradient,
DiagonalGradient,
CrossDiagonalGradient,
PyramidGradient,
RectangleGradient,
PipeCrossGradient,
EllipticGradient
};
enum RGBComponent { Red,
Green,
Blue,
Gray,
All
};
enum Lighting {NorthLite,
NWLite,
WestLite,
SWLite,
SouthLite,
SELite,
EastLite,
NELite
};
enum ModulationType { Intensity,
Saturation,
HueShift,
Contrast
};
enum NoiseType { UniformNoise=0,
GaussianNoise,
MultiplicativeGaussianNoise,
ImpulseNoise,
LaplacianNoise,
PoissonNoise
};
enum RotateDirection{ Rotate90,
Rotate180,
Rotate270
};
enum BumpmapType {
Linear,
Spherical,
Sinuosidal
};
static QImage gradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int ncols=3);
static QImage unbalancedGradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int xfactor = 100,
int yfactor = 100, int ncols = 3);
static QImage& blend(const QColor& clr, QImage& dst, float opacity);
static QImage& blend(QImage& src, QImage& dst, float opacity);
static QImage& blend(QImage &image, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir=false);
static QImage& blend(QImage &image1,QImage &image2,
GradientType gt, int xf=100, int yf=100);
static QImage& blend(QImage &image1, QImage &image2,
QImage &blendImage, RGBComponent channel);
static bool blend(const QImage & upper, const QImage & lower, QImage & output);
// Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
QImage &lower, const QRect &lowerRect);
static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
QImage &lower, const QRect &lowerRect, float opacity);
enum Disposition { NoImage = 0,
Centered,
Tiled,
CenterTiled,
CenteredMaxpect,
TiledMaxpect,
Scaled,
CenteredAutoFit
};
static QRect computeDestinationRect(const QSize &lowerSize,
Disposition disposition, QImage &upper);
static void blendOnLower(QImage &upper, QImage &lower,
Disposition disposition, float opacity);
static QImage& channelIntensity(QImage &image, float percent,
RGBComponent channel);
static QImage& fade(QImage &image, float val, const QColor &color);
static QImage& flatten(QImage &image, const QColor &ca,
const QColor &cb, int ncols=0);
static QImage& hash(QImage &image, Lighting lite=NorthLite,
unsigned int spacing=0);
static QImage& intensity(QImage &image, float percent);
static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
ModulationType type, int factor, RGBComponent channel);
static QImage& toGray(QImage &image, bool fast = false);
static QImage& desaturate(QImage &image, float desat = 0.3);
static QImage& contrast(QImage &image, int c);
static QImage& dither(QImage &image, const QColor *palette, int size);
static QImage& selectedImage( QImage &img, const QColor &col );
static void contrastHSV(QImage &img, bool sharpen=true);
static void normalize(QImage &img);
static void equalize(QImage &img);
static void threshold(QImage &img, unsigned int value=128);
static void solarize(QImage &img, double factor=50.0);
static QImage emboss(QImage &src, double radius, double sigma);
static QImage emboss(QImage &src);
static QImage despeckle(QImage &src);
static QImage charcoal(QImage &src, double radius, double sigma);
static QImage charcoal(QImage &src, double factor=50.0);
static QImage rotate(QImage &src, RotateDirection r);
static QImage sample(QImage &src, int w, int h);
static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
static QImage blur(QImage &src, double radius, double sigma);
static QImage blur(QImage &src, double factor=50.0);
static QImage edge(QImage &src, double radius);
static QImage implode(QImage &src, double factor=30.0,
unsigned int background = 0xFFFFFFFF);
static QImage oilPaintConvolve(QImage &src, double radius);
static QImage oilPaint(QImage &src, int radius=3);
static QImage sharpen(QImage &src, double radius, double sigma);
static QImage sharpen(QImage &src, double factor=30.0);
static QImage spread(QImage &src, unsigned int amount=3);
static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
double elevation=30.0);
static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
0xFFFFFFFF);
static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
unsigned int background = 0xFFFFFFFF);
static QImage bumpmap(QImage &img, QImage &map, double azimuth, double elevation,
int depth, int xofs, int yofs, int waterlevel,
int ambient, bool compensate, bool invert,
BumpmapType type, bool tiled);
private:
static unsigned int lHash(unsigned int c);
static unsigned int uHash(unsigned int c);
static int nearestColor( int r, int g, int b, const QColor *pal, int size );
static void hull(const int x_offset, const int y_offset, const int polarity,
const int width, const int height,
unsigned int *f, unsigned int *g);
static unsigned int generateNoise(unsigned int pixel, NoiseType type);
static unsigned int interpolateColor(QImage *image, double x, double y,
unsigned int background);
/* Various convolve routines */
static int getOptimalKernelWidth(double radius, double sigma);
static bool convolveImage(QImage *image, QImage *dest,
const unsigned int order,
const double *kernel);
static void blurScanLine(double *kernel, int width,
unsigned int *src, unsigned int *dest,
int columns);
static int getBlurKernel(int width, double sigma, double **kernel);
};
#endif
KImageEffect::NWLite
Lighting from the top left of the image.
Definition: kimageeffect.h:85
KImageEffect::GaussianNoise
Gaussian distribution.
Definition: kimageeffect.h:109
KImageEffect::Lighting
Lighting
This enum provides a lighting direction specification.
Definition: kimageeffect.h:84
KImageEffect::Gray
Grey channel.
Definition: kimageeffect.h:76
KImageEffect::ModulationType
ModulationType
This enum provides a modulation type specification.
Definition: kimageeffect.h:98
KImageEffect::BumpmapType
BumpmapType
This enum lists possible bumpmapping implementations.
Definition: kimageeffect.h:129
KImageEffect::ImpulseNoise
Impulse distribution.
Definition: kimageeffect.h:111
KImageEffect::SELite
Lighting from the bottom right of the image.
Definition: kimageeffect.h:89
KImageEffect::CenteredMaxpect
Center and scale aspect.
Definition: kimageeffect.h:330
KImageEffect::MultiplicativeGaussianNoise
Multiplicative Gaussian distribution.
Definition: kimageeffect.h:110
KImageEffect::GradientType
GradientType
This enum provides a gradient type specification.
Definition: kimageeffect.h:58
KImageEffect::RGBComponent
RGBComponent
This enum provides a RGB channel specification.
Definition: kimageeffect.h:73
KImageEffect::Tiled
Tile top image on bottom image.
Definition: kimageeffect.h:328
KImageEffect::WestLite
Lighting from the left of the image.
Definition: kimageeffect.h:86
KImageEffect::NorthLite
Lighting from the top of the image.
Definition: kimageeffect.h:84
KImageEffect::RotateDirection
RotateDirection
This enum provides a rotation specification.
Definition: kimageeffect.h:120
KImageEffect::Green
Green channel.
Definition: kimageeffect.h:74
KImageEffect::NoiseType
NoiseType
This enum provides a noise type specification.
Definition: kimageeffect.h:108
KImageEffect
This class includes various QImage based graphical effects.
Definition: kimageeffect.h:50
KImageEffect::Centered
Center top image on botton image.
Definition: kimageeffect.h:327
KImageEffect::HueShift
Modulate image hue.
Definition: kimageeffect.h:100
KImageEffect::Rotate180
Rotate 180 degrees.
Definition: kimageeffect.h:121
KImageEffect::Scaled
Scale.
Definition: kimageeffect.h:332
KImageEffect::TiledMaxpect
Tile and scale aspect.
Definition: kimageeffect.h:331
KImageEffect::Disposition
Disposition
Disposition of a source image on top of a destination image.
Definition: kimageeffect.h:326
KImageEffect::Saturation
Modulate image saturation.
Definition: kimageeffect.h:99
KImageEffect::LaplacianNoise
Laplacian distribution.
Definition: kimageeffect.h:112
KImageEffect::EastLite
Lighting from the right of the image.
Definition: kimageeffect.h:90
KImageEffect::CenterTiled
Center and tile top image on bottom image.
Definition: kimageeffect.h:329
KImageEffect::SouthLite
Lighting from the bottom of the image.
Definition: kimageeffect.h:88
KImageEffect::SWLite
Lighting from the bottom left of the image.
Definition: kimageeffect.h:87
KImageEffect::Blue
Blue channel.
Definition: kimageeffect.h:75

KDE Home | KDE Accessibility Home | Description of Access Keys