86{
87
88 QImage originalImage( filename );
89
90
91 if( originalImage.depth() < 32 ) { originalImage = originalImage.convertDepth( 32, Qt::AutoColor ); }
92
93
95
96
98 {
100 editedImage =
new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
101 delete tmp; tmp=NULL;
102 }
103
104
105 bool useBusyIndicators = false;
107 if( options != NULL && options->
getStatus() != NULL )
108 {
109 useBusyIndicators = true;
111 }
112
113
114 if(useBusyIndicators)
115 {
116 QString statusMessage = qApp->translate( "embossEffect", "Applying Emboss Effect:" );
118 qApp->processEvents();
119 }
120
121
122 const int updateIncrement = (int) ( 0.01 * originalImage.width() * originalImage.height() );
124
125
126 int x, y;
127 QRgb* rgb;
128 uchar* scanLine;
129
130 int yPrev, yNext, xPrev, xNext;
131
132
134 const int embossRadius = (int)
MAX( 1, (sqrt(minDimen)/8) );
135
137 {
138 scanLine = originalImage.scanLine(y);
139
140
141 yPrev =
MAX( y-embossRadius, 0 );
143
144
146 {
147
148 xPrev =
MAX( x-embossRadius, 0 );
150
151
152 int sum = 128;
153
154
155 scanLine = originalImage.scanLine( yPrev );
156 sum-= qGray( *((QRgb*)scanLine + xPrev ) );
157 sum-= qGray( *((QRgb*)scanLine + x ) );
158
159 scanLine = originalImage.scanLine( y );
160 sum-= qGray( *((QRgb*)scanLine + xPrev ) );
161 sum+= qGray( *((QRgb*)scanLine + xNext ) );
162
163 scanLine = originalImage.scanLine( yNext );
164 sum+= qGray( *((QRgb*)scanLine + x ) );
165 sum+= qGray( *((QRgb*)scanLine + xNext ) );
166
167
168 sum =
MAX(
MIN( sum, 255), 0 );
169
170
172 rgb = ((QRgb*)scanLine+x);
173 double r = ((double)qRed(*rgb) )/255.0;
174 double g = ((double)qGreen(*rgb) )/255.0;
175 double b = ((double)qBlue(*rgb) )/255.0;
176
177
178 double h,s,v;
180
181
182 v = ((double)sum)/255;
183
184
186 int rp = (int)
MIN(
MAX((r*255), 0), 255 );
187 int gp = (int)
MIN(
MAX((g*255), 0), 255 );
188 int bp = (int)
MIN(
MAX((
b*255), 0), 255 );
189
190
191 *rgb = qRgb(rp,gp,bp);
192
193
194 if(useBusyIndicators)
195 {
198 {
201 qApp->processEvents();
202 }
203 }
204
205 }
206 }
207
208
210}
StatusWidget * getStatus()