1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2005-05-25
* Description : Blur FX threaded image filter.
*
* Copyright 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright 2006-2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
*
* Original Blur algorithms copyrighted 2004 by
* Pieter Z. Voloshyn <pieter dot voloshyn at gmail dot com>.
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef BLURFX_H
#define BLURFX_H
// Digikam includes.
#include "dimgthreadedfilter.h"
namespace DigikamBlurFXImagesPlugin
{
class BlurFX : public Digikam::DImgThreadedFilter
{
public:
BlurFX(Digikam::DImg *orgImage, TQObject *parent=0, int blurFXType=ZoomBlur,
int distance=100, int level=45);
~BlurFX(){};
public:
enum BlurFXTypes
{
ZoomBlur=0,
RadialBlur,
FarBlur,
MotionBlur,
SoftenerBlur,
ShakeBlur,
FocusBlur,
SmartBlur,
FrostGlass,
Mosaic
};
private: // BlurFX filter data.
int m_blurFXType;
int m_distance;
int m_level;
private: // BlurFX filter methods.
virtual void filterImage(void);
// Backported from ImageProcessing version 1
void softenerBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage);
void shakeBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Distance);
void frostGlass(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Frost);
// Backported from ImageProcessing version 2
void zoomBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage,
int X, int Y, int Distance, TQRect pArea=TQRect());
void radialBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage,
int X, int Y, int Distance, TQRect pArea=TQRect());
void focusBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage,
int X, int Y, int BlurRadius, int BlendRadius,
bool bInversed=false, TQRect pArea=TQRect());
void farBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Distance);
void motionBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Distance, double Angle=0.0);
void smartBlur(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Radius, int Strenght);
void mosaic(Digikam::DImg *orgImage, Digikam::DImg *destImage, int SizeW, int SizeH);
private: // Internal filter methods.
void MakeConvolution(Digikam::DImg *orgImage, Digikam::DImg *destImage, int Radius, int Kernel[]);
Digikam::DColor RandomColor(uchar *Bits, int Width, int Height, bool sixteenBit, int bytesDepth,
int X, int Y, int Radius,
int alpha, uint *randomSeed, int range, uchar *IntensityCount,
uint *AverageColorR, uint *AverageColorG, uint *AverageColorB);
// Return the limit defined the max and min values.
inline int Lim_Max(int Now, int Up, int Max)
{
--Max;
while (Now > Max - Up) --Up;
return (Up);
};
// Return the luminance (Y) component of YIQ color model.
inline int GetIntensity (int R, int G, int B)
{
return (int)(R * 0.3 + G * 0.59 + B * 0.11);
};
// function to allocate a 2d array
inline int** Alloc2DArray (int Columns, int Rows)
{
// First, we declare our future 2d array to be returned
int** lpcArray = NULL;
// Now, we alloc the main pointer with Columns
lpcArray = new int*[Columns];
for (int i = 0; i < Columns; i++)
lpcArray[i] = new int[Rows];
return (lpcArray);
}
// Function to deallocates the 2d array previously created
inline void Free2DArray (int** lpcArray, int Columns)
{
// loop to dealocate the columns
for (int i = 0; i < Columns; i++)
delete [] lpcArray[i];
// now, we delete the main pointer
delete [] lpcArray;
}
inline bool IsInside (int Width, int Height, int X, int Y)
{
bool bIsWOk = ((X < 0) ? false : (X >= Width ) ? false : true);
bool bIsHOk = ((Y < 0) ? false : (Y >= Height) ? false : true);
return (bIsWOk && bIsHOk);
};
inline uchar LimitValues8(int ColorValue)
{
if (ColorValue > 255) ColorValue = 255;
if (ColorValue < 0) ColorValue = 0;
return ((uchar) ColorValue);
};
inline int LimitValues16(int ColorValue)
{
if (ColorValue > 65535) ColorValue = 65535;
if (ColorValue < 0) ColorValue = 0;
return ColorValue;
};
inline int GetOffset(int Width, int X, int Y, int bytesDepth)
{
return (Y * Width * bytesDepth) + (X * bytesDepth);
};
inline int GetOffsetAdjusted(int Width, int Height, int X, int Y, int bytesDepth)
{
X = (X < 0) ? 0 : ((X >= Width ) ? (Width - 1) : X);
Y = (Y < 0) ? 0 : ((Y >= Height) ? (Height - 1) : Y);
return GetOffset(Width, X, Y, bytesDepth);
};
inline bool IsColorInsideTheRange (int cR, int cG, int cB,
int nR, int nG, int nB,
int Range)
{
if ((nR >= cR - Range) && (nR <= cR + Range))
if ((nG >= cG - Range) && (nG <= cG + Range))
if ((nB >= cB - Range) && (nB <= cB + Range))
return (true);
return (false);
};
};
} // NameSpace DigikamBlurFXImagesPlugin
#endif /* BLURFX_H */
|