00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __KIMAGE_EFFECT_H
00032 #define __KIMAGE_EFFECT_H
00033
00034 class QImage;
00035 class QSize;
00036 class QColor;
00037
00047 class KImageEffect
00048 {
00049 public:
00050 enum GradientType { VerticalGradient, HorizontalGradient,
00051 DiagonalGradient, CrossDiagonalGradient,
00052 PyramidGradient, RectangleGradient,
00053 PipeCrossGradient, EllipticGradient };
00054 enum RGBComponent { Red, Green, Blue, Gray, All };
00055
00056 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
00057 SouthLite, SELite, EastLite, NELite};
00058
00059 enum ModulationType { Intensity, Saturation, HueShift, Contrast };
00060
00061 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
00062 ImpulseNoise, LaplacianNoise, PoissonNoise};
00063
00064 enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
00065
00077 static QImage gradient(const QSize &size, const QColor &ca,
00078 const QColor &cb, GradientType type, int ncols=3);
00079
00094 static QImage unbalancedGradient(const QSize &size, const QColor &ca,
00095 const QColor &cb, GradientType type, int xfactor = 100,
00096 int yfactor = 100, int ncols = 3);
00097
00110 static QImage& blend(const QColor& clr, QImage& dst, float opacity);
00111
00124 static QImage& blend(QImage& src, QImage& dst, float opacity);
00125
00140 static QImage& blend(QImage &image, float initial_intensity,
00141 const QColor &bgnd, GradientType eff,
00142 bool anti_dir=false);
00143
00154 static QImage& blend(QImage &image1,QImage &image2,
00155 GradientType gt, int xf=100, int yf=100);
00156
00169 static QImage& blend(QImage &image1, QImage &image2,
00170 QImage &blendImage, RGBComponent channel);
00171
00176 static bool blend(const QImage & upper, const QImage & lower, QImage & output);
00177
00178
00190 static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
00197 static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
00198
00208 static QImage& channelIntensity(QImage &image, float percent,
00209 RGBComponent channel);
00210
00221 static QImage& fade(QImage &img, float val, const QColor &color);
00222
00223
00232 static QImage& flatten(QImage &image, const QColor &ca,
00233 const QColor &cb, int ncols=0);
00234
00243 static QImage& hash(QImage &image, Lighting lite=NorthLite,
00244 unsigned int spacing=0);
00245
00255 static QImage& intensity(QImage &image, float percent);
00256
00268 static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
00269 ModulationType type, int factor, RGBComponent channel);
00270
00280 static QImage& toGray(QImage &image, bool fast = false);
00281
00289 static QImage& desaturate(QImage &image, float desat = 0.3);
00290
00299 static QImage& contrast(QImage &image, int c);
00300
00310 static QImage& dither(QImage &img, const QColor *palette, int size);
00311
00318 static QImage& selectedImage( QImage &img, const QColor &col );
00319
00331 static void contrastHSV(QImage &img, bool sharpen=true);
00332
00338 static void normalize(QImage &img);
00339
00345 static void equalize(QImage &img);
00346
00356 static void threshold(QImage &img, unsigned int value=128);
00357
00366 static void solarize(QImage &img, double factor=50.0);
00367
00377 static QImage emboss(QImage &src);
00378
00387 static QImage despeckle(QImage &src);
00388
00397 static QImage charcoal(QImage &src, double factor=50.0);
00398
00407 static QImage rotate(QImage &src, RotateDirection r);
00408
00420 static QImage sample(QImage &src, int w, int h);
00421
00430 static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
00431
00440 static QImage blur(QImage &src, double factor=50.0);
00441
00451 static QImage edge(QImage &src, double factor=50.0);
00452
00463 static QImage implode(QImage &src, double factor=30.0,
00464 unsigned int background = 0xFFFFFFFF);
00474 static QImage oilPaint(QImage &src, int radius=3);
00475
00484 static QImage sharpen(QImage &src, double factor=30.0);
00485
00494 static QImage spread(QImage &src, unsigned int amount=3);
00495
00506 static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
00507 double elevation=30.0);
00518 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
00519 0xFFFFFFFF);
00520
00530 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
00531 unsigned int background = 0xFFFFFFFF);
00532
00533 private:
00534
00539 static unsigned int lHash(unsigned int c);
00540 static unsigned int uHash(unsigned int c);
00541
00545 static int nearestColor( int r, int g, int b, const QColor *pal, int size );
00546
00547 static void hull(const int x_offset, const int y_offset, const int polarity,
00548 const int width, const int height,
00549 unsigned int *f, unsigned int *g);
00550 static unsigned int generateNoise(unsigned int pixel, NoiseType type);
00551 static unsigned int interpolateColor(QImage *image, double x, double y,
00552 unsigned int background);
00553 };
00554
00555 #endif