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.39 2004/06/12 21:03:57 waba Exp $
00030 
00031 #ifndef __KIMAGE_EFFECT_H
00032 #define __KIMAGE_EFFECT_H
00033 
00034 class QImage;
00035 class QSize;
00036 class QColor;
00037 class QPoint;
00038 class QRect;
00039 
00048 class KImageEffect
00049 {
00050 public:
00056     enum GradientType { VerticalGradient,
00057             HorizontalGradient,
00058                         DiagonalGradient,
00059             CrossDiagonalGradient,
00060                         PyramidGradient,
00061             RectangleGradient,
00062                         PipeCrossGradient,
00063             EllipticGradient
00064     };
00065 
00071     enum RGBComponent { Red,   
00072             Green, 
00073             Blue,  
00074             Gray,  
00075             All    
00076     };
00077 
00082     enum Lighting {NorthLite, 
00083            NWLite,    
00084            WestLite,  
00085            SWLite,    
00086                    SouthLite, 
00087            SELite,    
00088            EastLite,  
00089            NELite     
00090     };
00091 
00096     enum ModulationType { Intensity,  
00097               Saturation, 
00098               HueShift,   
00099               Contrast    
00100     };
00101 
00106     enum NoiseType { UniformNoise=0,              
00107              GaussianNoise,               
00108              MultiplicativeGaussianNoise, 
00109                      ImpulseNoise,                
00110              LaplacianNoise,              
00111              PoissonNoise                 
00112     };
00113 
00118     enum RotateDirection{ Rotate90,  
00119               Rotate180, 
00120               Rotate270  
00121     };
00122 
00127     enum BumpmapType {
00128         Linear,
00129         Spherical,
00130         Sinuosidal
00131     };
00132 
00144     static QImage gradient(const QSize &size, const QColor &ca,
00145                            const QColor &cb, GradientType type, int ncols=3);
00146 
00161     static QImage unbalancedGradient(const QSize &size, const QColor &ca,
00162         const QColor &cb, GradientType type, int xfactor = 100,
00163         int yfactor = 100, int ncols = 3);
00164 
00181     static QImage& blend(const QColor& clr, QImage& dst, float opacity);
00182 
00199     static QImage& blend(QImage& src, QImage& dst, float opacity);
00200 
00215     static QImage& blend(QImage &image, float initial_intensity,
00216                       const QColor &bgnd, GradientType eff,
00217                       bool anti_dir=false);
00218 
00229     static QImage& blend(QImage &image1,QImage &image2,
00230              GradientType gt, int xf=100, int yf=100);
00231 
00244     static QImage& blend(QImage &image1, QImage &image2,
00245              QImage &blendImage, RGBComponent channel);
00246 
00254     static bool blend(const QImage & upper, const QImage & lower, QImage & output);
00255 // Not yet...    static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
00256 
00273     static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
00274 
00285     static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
00286 
00299     static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
00300                              QImage &lower, const QRect &lowerRect);
00301 
00316     static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
00317                              QImage &lower, const QRect &lowerRect, float opacity);
00318 
00324     enum Disposition { NoImage = 0, 
00325                Centered,    
00326                Tiled,       
00327                CenterTiled, 
00328                CenteredMaxpect, 
00329                TiledMaxpect, 
00330                Scaled,      
00331                CenteredAutoFit 
00332     };
00333 
00348     static QRect computeDestinationRect(const QSize &lowerSize,
00349                                       Disposition disposition, QImage &upper);
00350 
00357     static void blendOnLower(QImage &upper, QImage &lower,
00358                              Disposition disposition, float opacity);
00359 
00369     static QImage& channelIntensity(QImage &image, float percent,
00370                                     RGBComponent channel);
00371 
00382     static QImage& fade(QImage &image, float val, const QColor &color);
00383 
00384 
00395     static QImage& flatten(QImage &image, const QColor &ca,
00396            const QColor &cb, int ncols=0);
00397 
00406     static QImage& hash(QImage &image, Lighting lite=NorthLite,
00407                         unsigned int spacing=0);
00408 
00422     static QImage& intensity(QImage &image, float percent);
00423 
00435     static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
00436         ModulationType type, int factor, RGBComponent channel);
00437 
00447     static QImage& toGray(QImage &image, bool fast = false);
00448 
00456     static QImage& desaturate(QImage &image, float desat = 0.3);
00457 
00467     static QImage& contrast(QImage &image, int c);
00468 
00478     static QImage& dither(QImage &image, const QColor *palette, int size);
00479 
00486     static QImage& selectedImage( QImage &img, const QColor &col );
00487 
00499     static void contrastHSV(QImage &img, bool sharpen=true);
00500 
00507     static void normalize(QImage &img);
00508 
00515     static void equalize(QImage &img);
00516 
00526     static void threshold(QImage &img, unsigned int value=128);
00527 
00536     static void solarize(QImage &img, double factor=50.0);
00537 
00551     static QImage emboss(QImage &src, double radius, double sigma);
00552 
00556     static QImage emboss(QImage &src);
00557 
00566     static QImage despeckle(QImage &src);
00567 
00579     static QImage charcoal(QImage &src, double radius, double sigma);
00580 
00585      static QImage charcoal(QImage &src, double factor=50.0);
00586 
00595     static QImage rotate(QImage &src, RotateDirection r);
00596 
00608     static QImage sample(QImage &src, int w, int h);
00609 
00618     static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
00619 
00631     static QImage blur(QImage &src, double radius, double sigma);
00632 
00637     static QImage blur(QImage &src, double factor=50.0);
00638 
00649     static QImage edge(QImage &src, double radius);
00650 
00661     static QImage implode(QImage &src, double factor=30.0,
00662                    unsigned int background = 0xFFFFFFFF);
00663 
00673     static QImage oilPaintConvolve(QImage &src, double radius);
00674 
00679     static QImage oilPaint(QImage &src, int radius=3);
00680 
00692     static QImage sharpen(QImage &src, double radius, double sigma);
00693 
00698     static QImage sharpen(QImage &src, double factor=30.0);
00699 
00708     static QImage spread(QImage &src, unsigned int amount=3);
00709 
00720     static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
00721                         double elevation=30.0);
00732     static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
00733                          0xFFFFFFFF);
00734 
00746     static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
00747                         unsigned int background = 0xFFFFFFFF);
00748 
00768     static QImage bumpmap(QImage &img, QImage &map, double azimuth, double elevation,
00769                           int depth, int xofs, int yofs, int waterlevel,
00770                           int ambient, bool compensate, bool invert,
00771                           BumpmapType type, bool tiled);
00772 
00773 private:
00774 
00779     static unsigned int lHash(unsigned int c);
00780     static unsigned int uHash(unsigned int c);
00781 
00785     static int nearestColor( int r, int g, int b, const QColor *pal, int size );
00786 
00787     static void hull(const int x_offset, const int y_offset, const int polarity,
00788                      const int width, const int height,
00789                      unsigned int *f, unsigned int *g);
00790     static unsigned int generateNoise(unsigned int pixel, NoiseType type);
00791     static unsigned int interpolateColor(QImage *image, double x, double y,
00792                                          unsigned int background);
00793     /* Various convolve routines */
00794     static int getOptimalKernelWidth(double radius, double sigma);
00795     static bool convolveImage(QImage *image, QImage *dest,
00796                               const unsigned int order,
00797                               const double *kernel);
00798     static void blurScanLine(double *kernel, int width,
00799                              unsigned int *src, unsigned int *dest,
00800                              int columns);
00801     static int getBlurKernel(int width, double sigma, double **kernel);
00802 };
00803 
00804 #endif
KDE Logo
This file is part of the documentation for kdefx Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:32:15 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003