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
00032
00033
00034
00035 #ifndef OIMAGEEFFECT_H
00036 #define OIMAGEEFFECT_H
00037
00038 class QImage;
00039 class QSize;
00040 class QColor;
00041
00042 namespace Opie {
00043 namespace Ui {
00053 class OImageEffect
00054 {
00055 public:
00056 enum GradientType { VerticalGradient, HorizontalGradient,
00057 DiagonalGradient, CrossDiagonalGradient,
00058 PyramidGradient, RectangleGradient,
00059 PipeCrossGradient, EllipticGradient };
00060 enum RGBComponent { Red, Green, Blue, Gray, All };
00061
00062 enum Lighting {NorthLite, NWLite, WestLite, SWLite,
00063 SouthLite, SELite, EastLite, NELite};
00064
00065 enum ModulationType { Intensity, Saturation, HueShift, Contrast };
00066
00067 enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
00068 ImpulseNoise, LaplacianNoise, PoissonNoise};
00069
00070 enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
00071
00083 static QImage gradient(const QSize &size, const QColor &ca,
00084 const QColor &cb, GradientType type, int ncols=3);
00085
00100 static QImage unbalancedGradient(const QSize &size, const QColor &ca,
00101 const QColor &cb, GradientType type, int xfactor = 100,
00102 int yfactor = 100, int ncols = 3);
00103
00116 static QImage& blend(const QColor& clr, QImage& dst, float opacity);
00117
00130 static QImage& blend(QImage& src, QImage& dst, float opacity);
00131
00146 static QImage& blend(QImage &image, float initial_intensity,
00147 const QColor &bgnd, GradientType eff,
00148 bool anti_dir=false);
00149
00160 static QImage& blend(QImage &image1,QImage &image2,
00161 GradientType gt, int xf=100, int yf=100);
00162
00175 static QImage& blend(QImage &image1, QImage &image2,
00176 QImage &blendImage, RGBComponent channel);
00177
00182 static bool blend(const QImage & upper, const QImage & lower, QImage & output);
00183
00184
00196 static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
00203 static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
00204
00214 static QImage& channelIntensity(QImage &image, float percent,
00215 RGBComponent channel);
00216
00227 static QImage& fade(QImage &img, float val, const QColor &color);
00228
00229
00238 static QImage& flatten(QImage &image, const QColor &ca,
00239 const QColor &cb, int ncols=0);
00240
00249 static QImage& hash(QImage &image, Lighting lite=NorthLite,
00250 unsigned int spacing=0);
00251
00261 static QImage& intensity(QImage &image, float percent);
00262
00274 static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
00275 ModulationType type, int factor, RGBComponent channel);
00276
00286 static QImage& toGray(QImage &image, bool fast = false);
00287
00295 static QImage& desaturate(QImage &image, float desat = 0.3);
00296
00305 static QImage& contrast(QImage &image, int c);
00306
00316 static QImage& dither(QImage &img, const QColor *palette, int size);
00317
00324 static QImage& selectedImage( QImage &img, const QColor &col );
00325
00337 static void contrastHSV(QImage &img, bool sharpen=true);
00338
00344 static void normalize(QImage &img);
00345
00351 static void equalize(QImage &img);
00352
00362 static void threshold(QImage &img, unsigned int value=128);
00363
00372 static void solarize(QImage &img, double factor=50.0);
00373
00383 static QImage emboss(QImage &src);
00384
00393 static QImage despeckle(QImage &src);
00394
00403 static QImage charcoal(QImage &src, double factor=50.0);
00404
00413 static QImage rotate(QImage &src, RotateDirection r);
00414
00426 static QImage sample(QImage &src, int w, int h);
00427
00436 static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
00437
00446 static QImage blur(QImage &src, double factor=50.0);
00447
00457 static QImage edge(QImage &src, double factor=50.0);
00458
00469 static QImage implode(QImage &src, double factor=30.0,
00470 unsigned int background = 0xFFFFFFFF);
00480 static QImage oilPaint(QImage &src, int radius=3);
00481
00490 static QImage sharpen(QImage &src, double factor=30.0);
00491
00500 static QImage spread(QImage &src, unsigned int amount=3);
00501
00512 static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
00513 double elevation=30.0);
00524 static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
00525 0xFFFFFFFF);
00526
00536 static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
00537 unsigned int background = 0xFFFFFFFF);
00538
00539 private:
00540
00545 static unsigned int lHash(unsigned int c);
00546 static unsigned int uHash(unsigned int c);
00547
00551 static int nearestColor( int r, int g, int b, const QColor *pal, int size );
00552
00553 static void hull(const int x_offset, const int y_offset, const int polarity,
00554 const int width, const int height,
00555 unsigned int *f, unsigned int *g);
00556 static unsigned int generateNoise(unsigned int pixel, NoiseType type);
00557 static unsigned int interpolateColor(QImage *image, double x, double y,
00558 unsigned int background);
00559 };
00560
00561 }
00562 }
00563
00564 #endif