kdefx Library API Documentation

kimageeffect.h

00001 /* This file is part of the KDE libraries
00002  Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
00003  (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
00004  (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions
00008 are met:
00009 
00010 1. Redistributions of source code must retain the above copyright
00011    notice, this list of conditions and the following disclaimer.
00012 2. Redistributions in binary form must reproduce the above copyright
00013    notice, this list of conditions and the following disclaimer in the
00014    documentation and/or other materials provided with the distribution.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 */
00028 
00029 // $Id: kimageeffect.h,v 1.25 2002/07/31 23:14:10 orlovich Exp $
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 // Not yet...    static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
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
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:30 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001