1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Distortion FX threaded image filter.
9
* Copyright (C) 2005-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
* Copyright (C) 2006-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12
* Original Distortion algorithms copyrighted 2004-2005 by
13
* Pieter Z. Voloshyn <pieter dot voloshyn at gmail dot com>.
15
* This program is free software; you can redistribute it
16
* and/or modify it under the terms of the GNU General
17
* Public License as published by the Free Software Foundation;
18
* either version 2, or (at your option)
21
* This program is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
* GNU General Public License for more details.
26
* ============================================================ */
28
#ifndef DISTORTION_FX_FILTER_H
29
#define DISTORTION_FX_FILTER_H
37
#include "digikam_export.h"
38
#include "dimgthreadedfilter.h"
44
class DIGIKAM_EXPORT DistortionFXFilter : public DImgThreadedFilter
49
explicit DistortionFXFilter(DImg* orgImage, QObject* parent=0, int effectType=0,
50
int level=0, int iteration=0, bool antialiasing=true);
52
~DistortionFXFilter(){};
56
enum DistortionFXTypes
80
// Backported from ImageProcessing version 2
81
void fisheye(DImg *orgImage, DImg *destImage, double Coeff, bool AntiAlias=true);
82
void twirl(DImg *orgImage, DImg *destImage, int Twirl, bool AntiAlias=true);
83
void cilindrical(DImg *orgImage, DImg *destImage, double Coeff,
84
bool Horizontal, bool Vertical, bool AntiAlias=true);
85
void multipleCorners(DImg *orgImage, DImg *destImage, int Factor, bool AntiAlias=true);
86
void polarCoordinates(DImg *orgImage, DImg *destImage, bool Type, bool AntiAlias=true);
87
void circularWaves(DImg *orgImage, DImg *destImage, int X, int Y, double Amplitude,
88
double Frequency, double Phase, bool WavesType, bool AntiAlias=true);
90
// Backported from ImageProcessing version 1
91
void waves(DImg *orgImage, DImg *destImage, int Amplitude, int Frequency,
92
bool FillSides, bool Direction);
93
void blockWaves(DImg *orgImage, DImg *destImage, int Amplitude, int Frequency, bool Mode);
94
void tile(DImg *orgImage, DImg *destImage, int WSize, int HSize, int Random);
96
void setPixelFromOther(int Width, int Height, bool sixteenBit, int bytesDepth,
97
uchar *data, uchar *pResBits,
98
int w, int h, double nw, double nh, bool AntiAlias);
102
inline double maximumRadius(int Height, int Width, double Angle);
104
// This function does the same thing that ShadeColors function but using double variables.
105
inline double proportionalValue (double DestValue, double SrcValue, double Shade)
107
if (Shade == 0.0) return DestValue;
108
if (Shade == 255.0) return SrcValue;
109
return ((DestValue * (255.0 - Shade) + SrcValue * Shade) / 256.0);
113
// Return the limit defined the max and min values.
114
inline int Lim_Max(int Now, int Up, int Max)
117
while (Now > Max - Up) --Up;
121
inline bool isInside (int Width, int Height, int X, int Y)
123
bool bIsWOk = ((X < 0) ? false : (X >= Width ) ? false : true);
124
bool bIsHOk = ((Y < 0) ? false : (Y >= Height) ? false : true);
125
return (bIsWOk && bIsHOk);
128
inline int getOffset(int Width, int X, int Y, int bytesDepth)
130
return (Y * Width * bytesDepth) + (X * bytesDepth);
133
inline int getOffsetAdjusted(int Width, int Height, int X, int Y, int bytesDepth)
135
X = (X < 0) ? 0 : ((X >= Width ) ? (Width - 1) : X);
136
Y = (Y < 0) ? 0 : ((Y >= Height) ? (Height - 1) : Y);
137
return getOffset(Width, X, Y, bytesDepth);
149
} // namespace Digikam
151
#endif /* DISTORTION_FX_FILTER_H */