77    static void convertToGrayscale( QImage &image, GrayscaleMode mode = GrayscaleLuminosity, 
QgsFeedback *feedback = 
nullptr );
 
   90    static void adjustBrightnessContrast( QImage &image, 
int brightness, 
double contrast, 
QgsFeedback *feedback = 
nullptr );
 
  101    static void adjustHueSaturation( QImage &image, 
double saturation, 
const QColor &colorizeColor = QColor(),
 
  102                                     double colorizeStrength = 1.0, 
QgsFeedback *feedback = 
nullptr );
 
  110    static void multiplyOpacity( QImage &image, 
double factor, 
QgsFeedback *feedback = 
nullptr );
 
  118    static void overlayColor( QImage &image, 
const QColor &color );
 
  129      bool shadeExterior = 
true;
 
  135      bool useMaxDistance = 
true;
 
  141      double spread = 10.0;
 
 
  169    static void stackBlur( QImage &image, 
int radius, 
bool alphaOnly = 
false, 
QgsFeedback *feedback = 
nullptr );
 
  187    static 
void flipImage( QImage &image, 
FlipType type );
 
  198    static QRect nonTransparentImageRect( const QImage &image, QSize minSize = QSize(), 
bool center = false );
 
  208    static QImage cropTransparent( const QImage &image, QSize minSize = QSize(), 
bool center = false );
 
  213    enum LineOperationDirection
 
  218    template <
class BlockOperation> 
static void runBlockOperationInThreads( QImage &image, BlockOperation &operation, LineOperationDirection direction );
 
  221      unsigned int beginLine;
 
  222      unsigned int endLine;
 
  223      unsigned int lineLength;
 
  224      QImage *image = 
nullptr;
 
  228    template <
typename RectOperation> 
static void runRectOperation( QImage &image, RectOperation &operation );
 
  229    template <
class RectOperation> 
static void runRectOperationOnWholeImage( QImage &image, RectOperation &operation );
 
  232    template <
class PixelOperation> 
static void runPixelOperation( QImage &image, PixelOperation &operation, 
QgsFeedback *feedback = 
nullptr );
 
  233    template <
class PixelOperation> 
static void runPixelOperationOnWholeImage( QImage &image, PixelOperation &operation, 
QgsFeedback *feedback = 
nullptr );
 
  234    template <
class PixelOperation>
 
  235    struct ProcessBlockUsingPixelOperation
 
  237      explicit ProcessBlockUsingPixelOperation( PixelOperation &operation, 
QgsFeedback *feedback )
 
  238        : mOperation( operation )
 
  239        , mFeedback( feedback )
 
  242      typedef void result_type;
 
  244      void operator()( ImageBlock &block )
 
  246        for ( 
unsigned int y = block.beginLine; y < block.endLine; ++y )
 
  248          if ( mFeedback && mFeedback->isCanceled() )
 
  251          QRgb *ref = 
reinterpret_cast< QRgb * 
>( block.image->scanLine( y ) );
 
  252          for ( 
unsigned int x = 0; x < block.lineLength; ++x )
 
  254            mOperation( ref[x], x, y );
 
  259      PixelOperation &mOperation;
 
  264    template <
typename LineOperation> 
static void runLineOperation( QImage &image, LineOperation &operation, 
QgsFeedback *feedback = 
nullptr );
 
  265    template <
class LineOperation> 
static void runLineOperationOnWholeImage( QImage &image, LineOperation &operation, 
QgsFeedback *feedback = 
nullptr );
 
  266    template <
class LineOperation>
 
  267    struct ProcessBlockUsingLineOperation
 
  269      explicit ProcessBlockUsingLineOperation( LineOperation &operation )
 
  270        : mOperation( operation ) { }
 
  272      typedef void result_type;
 
  274      void operator()( ImageBlock &block )
 
  277        int bpl = block.image->bytesPerLine();
 
  278        if ( mOperation.direction() == ByRow )
 
  280          for ( 
unsigned int y = block.beginLine; y < block.endLine; ++y )
 
  282            QRgb *ref = 
reinterpret_cast< QRgb * 
>( block.image->scanLine( y ) );
 
  283            mOperation( ref, block.lineLength, bpl );
 
  289          unsigned char *ref = block.image->scanLine( 0 ) + 4 * block.beginLine;
 
  290          for ( 
unsigned int x = block.beginLine; x < block.endLine; ++x, ref += 4 )
 
  292            mOperation( 
reinterpret_cast< QRgb * 
>( ref ), block.lineLength, bpl );
 
  297      LineOperation &mOperation;
 
  303    class GrayscalePixelOperation
 
  306        explicit GrayscalePixelOperation( 
const GrayscaleMode mode )
 
  310        void operator()( QRgb &rgb, 
int x, 
int y ) 
const;
 
  315    static void grayscaleLightnessOp( QRgb &rgb );
 
  316    static void grayscaleLuminosityOp( QRgb &rgb );
 
  317    static void grayscaleAverageOp( QRgb &rgb );
 
  320    class BrightnessContrastPixelOperation
 
  323        BrightnessContrastPixelOperation( 
const int brightness, 
const double contrast )
 
  324          : mBrightness( brightness )
 
  325          , mContrast( contrast )
 
  328        void operator()( QRgb &rgb, 
int x, 
int y ) 
const;
 
  336    class HueSaturationPixelOperation
 
  339        HueSaturationPixelOperation( 
const double saturation, 
const bool colorize,
 
  340                                     const int colorizeHue, 
const int colorizeSaturation,
 
  341                                     const double colorizeStrength )
 
  342          : mSaturation( saturation )
 
  343          , mColorize( colorize )
 
  344          , mColorizeHue( colorizeHue )
 
  345          , mColorizeSaturation( colorizeSaturation )
 
  346          , mColorizeStrength( colorizeStrength )
 
  349        void operator()( QRgb &rgb, 
int x, 
int y );
 
  355        int mColorizeSaturation;
 
  356        double mColorizeStrength; 
 
  358    static int adjustColorComponent( 
int colorComponent, 
int brightness, 
double contrastFactor );
 
  361    class MultiplyOpacityPixelOperation
 
  364        explicit MultiplyOpacityPixelOperation( 
const double factor )
 
  368        void operator()( QRgb &rgb, 
int x, 
int y );
 
  374    class ConvertToArrayPixelOperation
 
  377        ConvertToArrayPixelOperation( 
const int width, 
double *array, 
const bool exterior = 
true )
 
  380          , mExterior( exterior )
 
  384        void operator()( QRgb &rgb, 
int x, 
int y );
 
  388        double *mArray = 
nullptr;
 
  392    class ShadeFromArrayOperation
 
  395        ShadeFromArrayOperation( 
const int width, 
double *array, 
const double spread,
 
  396                                 const DistanceTransformProperties &properties )
 
  400          , mProperties( properties )
 
  402          mSpreadSquared = std::pow( mSpread, 2.0 );
 
  405        void operator()( QRgb &rgb, 
int x, 
int y );
 
  409        double *mArray = 
nullptr;
 
  411        double mSpreadSquared;
 
  412        const DistanceTransformProperties &mProperties;
 
  414    static void distanceTransform2d( 
double *im, 
int width, 
int height, 
QgsFeedback *feedback = 
nullptr );
 
  415    static void distanceTransform1d( 
double *f, 
int n, 
int *v, 
double *z, 
double *d );
 
  416    static double maxValueInDistanceTransformArray( 
const double *array, 
unsigned int size );
 
  419    class StackBlurLineOperation
 
  422        StackBlurLineOperation( 
int alpha, LineOperationDirection direction, 
bool forwardDirection, 
int i1, 
int i2, 
QgsFeedback *feedback )
 
  424          , mDirection( direction )
 
  425          , mForwardDirection( forwardDirection )
 
  428          , mFeedback( feedback )
 
  431        typedef void result_type;
 
  433        LineOperationDirection direction()
 const { 
return mDirection; }
 
  435        void operator()( QRgb *startRef, 
int lineLength, 
int bytesPerLine )
 
  437          if ( mFeedback && mFeedback->isCanceled() )
 
  440          unsigned char *p = 
reinterpret_cast< unsigned char * 
>( startRef );
 
  442          int increment = ( mDirection == QgsImageOperation::ByRow ) ? 4 : bytesPerLine;
 
  443          if ( !mForwardDirection )
 
  445            p += 
static_cast< std::size_t 
>( lineLength - 1 ) * increment;
 
  446            increment = -increment;
 
  449          for ( 
int i = mi1; i <= mi2; ++i )
 
  455          for ( 
int j = 1; j < lineLength; ++j, p += increment )
 
  457            if ( mFeedback && mFeedback->isCanceled() )
 
  460            for ( 
int i = mi1; i <= mi2; ++i )
 
  462              p[i] = ( rgba[i] += ( ( p[i] << 4 ) - rgba[i] ) * mAlpha / 16 ) >> 4;
 
  469        LineOperationDirection mDirection;
 
  470        bool mForwardDirection;
 
  476    static double *createGaussianKernel( 
int radius );
 
  478    class GaussianBlurOperation
 
  481        GaussianBlurOperation( 
int radius, LineOperationDirection direction, QImage *destImage, 
double *kernel, 
QgsFeedback *feedback )
 
  483          , mDirection( direction )
 
  484          , mDestImage( destImage )
 
  485          , mDestImageBpl( destImage->bytesPerLine() )
 
  487          , mFeedback( feedback )
 
  490        typedef void result_type;
 
  492        void operator()( ImageBlock &block );
 
  496        LineOperationDirection mDirection;
 
  497        QImage *mDestImage = 
nullptr;
 
  499        double *mKernel = 
nullptr;
 
  502        inline QRgb gaussianBlurVertical( 
int posy, 
unsigned char *sourceFirstLine, 
int sourceBpl, 
int height ) 
const;
 
  503        inline QRgb gaussianBlurHorizontal( 
int posx, 
unsigned char *sourceFirstLine, 
int width ) 
const;
 
  509    class FlipLineOperation
 
  512        explicit FlipLineOperation( LineOperationDirection direction )
 
  513          : mDirection( direction )
 
  516        typedef void result_type;
 
  518        LineOperationDirection direction()
 const { 
return mDirection; }
 
  520        void operator()( QRgb *startRef, 
int lineLength, 
int bytesPerLine ) 
const;
 
  523        LineOperationDirection mDirection;