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.37 2003/10/07 22:40:42 mueller 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 
00134     static QImage gradient(const QSize &size, const QColor &ca,
00135                            const QColor &cb, GradientType type, int ncols=3);
00136 
00151     static QImage unbalancedGradient(const QSize &size, const QColor &ca,
00152         const QColor &cb, GradientType type, int xfactor = 100,
00153         int yfactor = 100, int ncols = 3);
00154 
00171     static QImage& blend(const QColor& clr, QImage& dst, float opacity);
00172 
00189     static QImage& blend(QImage& src, QImage& dst, float opacity);
00190 
00205     static QImage& blend(QImage &image, float initial_intensity,
00206                       const QColor &bgnd, GradientType eff,
00207                       bool anti_dir=false);
00208 
00219     static QImage& blend(QImage &image1,QImage &image2,
00220              GradientType gt, int xf=100, int yf=100);
00221 
00234     static QImage& blend(QImage &image1, QImage &image2,
00235              QImage &blendImage, RGBComponent channel);
00236 
00244     static bool blend(const QImage & upper, const QImage & lower, QImage & output);
00245 // Not yet...    static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
00246 
00263     static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
00264 
00275     static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
00276 
00289     static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
00290                              QImage &lower, const QRect &lowerRect);
00291 
00306     static void blendOnLower(const QImage &upper, const QPoint &upperOffset,
00307                              QImage &lower, const QRect &lowerRect, float opacity);
00308 
00314     enum Disposition { NoImage = 0, 
00315                Centered,    
00316                Tiled,       
00317                CenterTiled, 
00318                CenteredMaxpect, 
00319                TiledMaxpect, 
00320                Scaled,      
00321                CenteredAutoFit 
00322     };
00323 
00338     static QRect computeDestinationRect(const QSize &lowerSize,
00339                                       Disposition disposition, QImage &upper);
00340 
00347     static void blendOnLower(QImage &upper, QImage &lower,
00348                              Disposition disposition, float opacity);
00349 
00359     static QImage& channelIntensity(QImage &image, float percent,
00360                                     RGBComponent channel);
00361 
00372     static QImage& fade(QImage &image, float val, const QColor &color);
00373 
00374 
00385     static QImage& flatten(QImage &image, const QColor &ca,
00386            const QColor &cb, int ncols=0);
00387 
00396     static QImage& hash(QImage &image, Lighting lite=NorthLite,
00397                         unsigned int spacing=0);
00398 
00412     static QImage& intensity(QImage &image, float percent);
00413 
00425     static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
00426         ModulationType type, int factor, RGBComponent channel);
00427 
00437     static QImage& toGray(QImage &image, bool fast = false);
00438 
00446     static QImage& desaturate(QImage &image, float desat = 0.3);
00447 
00456     static QImage& contrast(QImage &image, int c);
00457 
00467     static QImage& dither(QImage &image, const QColor *palette, int size);
00468 
00475     static QImage& selectedImage( QImage &img, const QColor &col );
00476 
00488     static void contrastHSV(QImage &img, bool sharpen=true);
00489 
00496     static void normalize(QImage &img);
00497 
00504     static void equalize(QImage &img);
00505 
00515     static void threshold(QImage &img, unsigned int value=128);
00516 
00525     static void solarize(QImage &img, double factor=50.0);
00526 
00540     static QImage emboss(QImage &src, double radius, double sigma);
00541 
00545     static QImage emboss(QImage &src);
00546 
00555     static QImage despeckle(QImage &src);
00556 
00568     static QImage charcoal(QImage &src, double radius, double sigma);
00569 
00574      static QImage charcoal(QImage &src, double factor=50.0);
00575 
00584     static QImage rotate(QImage &src, RotateDirection r);
00585 
00597     static QImage sample(QImage &src, int w, int h);
00598 
00607     static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
00608 
00620     static QImage blur(QImage &src, double radius, double sigma);
00621 
00626     static QImage blur(QImage &src, double factor=50.0);
00627 
00638     static QImage edge(QImage &src, double radius);
00639 
00650     static QImage implode(QImage &src, double factor=30.0,
00651                    unsigned int background = 0xFFFFFFFF);
00652 
00662     static QImage oilPaintConvolve(QImage &src, double radius);
00663 
00668     static QImage oilPaint(QImage &src, int radius=3);
00669 
00681     static QImage sharpen(QImage &src, double radius, double sigma);
00682 
00687     static QImage sharpen(QImage &src, double factor=30.0);
00688 
00697     static QImage spread(QImage &src, unsigned int amount=3);
00698 
00709     static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
00710                         double elevation=30.0);
00721      static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
00722                          0xFFFFFFFF);
00723 
00735      static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
00736                         unsigned int background = 0xFFFFFFFF);
00737 
00738 private:
00739 
00744     static unsigned int lHash(unsigned int c);
00745     static unsigned int uHash(unsigned int c);
00746 
00750     static int nearestColor( int r, int g, int b, const QColor *pal, int size );
00751 
00752     static void hull(const int x_offset, const int y_offset, const int polarity,
00753                      const int width, const int height,
00754                      unsigned int *f, unsigned int *g);
00755     static unsigned int generateNoise(unsigned int pixel, NoiseType type);
00756     static unsigned int interpolateColor(QImage *image, double x, double y,
00757                                          unsigned int background);
00758     /* Various convolve routines */
00759     static int getOptimalKernelWidth(double radius, double sigma);
00760     static bool convolveImage(QImage *image, QImage *dest,
00761                               const unsigned int order,
00762                               const double *kernel);
00763     static void blurScanLine(double *kernel, int width,
00764                              unsigned int *src, unsigned int *dest,
00765                              int columns);
00766     static int getBlurKernel(int width, double sigma, double **kernel);
00767 };
00768 
00769 #endif
KDE Logo
This file is part of the documentation for kdefx Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 5 07:19:26 2004 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003