Skip to content

Commit a1b858b

Browse files
committedFeb 9, 2015
[raster] Fix cubic resampler visual glitches (refs #6561)
Resampler was not correctly bounding color components for premultiplied image format. There's still errors in the resampled raster at the source image edges and glitches with transparency channels, though. Also fix a bunch of inefficiencies in the code.
1 parent 9fb0065 commit a1b858b

File tree

2 files changed

+144
-165
lines changed

2 files changed

+144
-165
lines changed
 

‎src/core/raster/qgscubicrasterresampler.cpp

Lines changed: 137 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "qgscubicrasterresampler.h"
1919
#include <QImage>
20-
#include <cmath>
20+
#include <qmath.h>
2121

2222
QgsCubicRasterResampler::QgsCubicRasterResampler()
2323
// red
@@ -56,16 +56,19 @@ void QgsCubicRasterResampler::resample( const QImage& srcImage, QImage& dstImage
5656
int *blueMatrix = new int[ nCols * nRows ];
5757
int *alphaMatrix = new int[ nCols * nRows ];
5858

59-
for ( int i = 0; i < nRows; ++i )
59+
for ( int heightIndex = 0; heightIndex < nRows; ++heightIndex )
6060
{
61-
for ( int j = 0; j < nCols; ++j )
61+
QRgb* scanLine = ( QRgb* )srcImage.constScanLine( heightIndex );
62+
for ( int widthIndex = 0; widthIndex < nCols; ++widthIndex )
6263
{
63-
px = srcImage.pixel( j, i );
64+
px = scanLine[widthIndex];
65+
int alpha = qAlpha( px );
66+
alphaMatrix[pos] = alpha;
6467
redMatrix[pos] = qRed( px );
6568
greenMatrix[pos] = qGreen( px );
6669
blueMatrix[pos] = qBlue( px );
67-
alphaMatrix[pos] = qAlpha( px );
68-
++pos;
70+
71+
pos++;
6972
}
7073
}
7174

@@ -97,82 +100,83 @@ void QgsCubicRasterResampler::resample( const QImage& srcImage, QImage& dstImage
97100
double currentSrcCol;
98101
int currentSrcColInt;
99102
int currentSrcRowInt;
100-
int lastSrcColInt = -1;
101-
int lastSrcRowInt = -1;
103+
int lastSrcColInt = -100;
104+
int lastSrcRowInt = -100;
102105

103-
int r, g, b, a;
104106
//bernstein polynomials
105107
double bp0u, bp1u, bp2u, bp3u, bp0v, bp1v, bp2v, bp3v;
106108
double u, v;
107109

108-
for ( int i = 0; i < dstImage.height(); ++i )
110+
for ( int y = 0; y < dstImage.height(); ++y )
109111
{
110112
currentSrcRowInt = floor( currentSrcRow );
111113
v = currentSrcRow - currentSrcRowInt;
112114

113115
currentSrcCol = nSrcPerDstX / 2.0 - 0.5;
114-
for ( int j = 0; j < dstImage.width(); ++j )
116+
117+
QRgb* scanLine = ( QRgb* )dstImage.scanLine( y );
118+
for ( int x = 0; x < dstImage.width(); ++x )
115119
{
116120
currentSrcColInt = floor( currentSrcCol );
117121
u = currentSrcCol - currentSrcColInt;
118122

119123
//handle eight edge-cases
120-
if ( currentSrcRowInt < 0 || currentSrcRowInt >= ( srcImage.height() - 1 ) || currentSrcColInt < 0 || currentSrcColInt >= ( srcImage.width() - 1 ) )
124+
if (( currentSrcRowInt < 0 || currentSrcRowInt >= ( srcImage.height() - 1 ) || currentSrcColInt < 0 || currentSrcColInt >= ( srcImage.width() - 1 ) ) )
121125
{
122126
QRgb px1, px2;
123127
//pixels at the border of the source image needs to be handled in a special way
124128
if ( currentSrcRowInt < 0 && currentSrcColInt < 0 )
125129
{
126-
dstImage.setPixel( j, i, srcImage.pixel( 0, 0 ) );
130+
scanLine[x] = srcImage.pixel( 0, 0 );
127131
}
128132
else if ( currentSrcRowInt < 0 && currentSrcColInt >= ( srcImage.width() - 1 ) )
129133
{
130-
dstImage.setPixel( j, i, srcImage.pixel( srcImage.width() - 1, 0 ) );
134+
scanLine[x] = srcImage.pixel( srcImage.width() - 1, 0 );
131135
}
132136
else if ( currentSrcRowInt >= ( srcImage.height() - 1 ) && currentSrcColInt >= ( srcImage.width() - 1 ) )
133137
{
134-
dstImage.setPixel( j, i, srcImage.pixel( srcImage.width() - 1, srcImage.height() - 1 ) );
138+
scanLine[x] = srcImage.pixel( srcImage.width() - 1, srcImage.height() - 1 );
135139
}
136140
else if ( currentSrcRowInt >= ( srcImage.height() - 1 ) && currentSrcColInt < 0 )
137141
{
138-
dstImage.setPixel( j, i, srcImage.pixel( 0, srcImage.height() - 1 ) );
142+
scanLine[x] = srcImage.pixel( 0, srcImage.height() - 1 );
139143
}
140144
else if ( currentSrcRowInt < 0 )
141145
{
142146
px1 = srcImage.pixel( currentSrcColInt, 0 );
143147
px2 = srcImage.pixel( currentSrcColInt + 1, 0 );
144-
dstImage.setPixel( j, i, curveInterpolation( px1, px2, u, xDerivativeMatrixRed[ currentSrcColInt ], xDerivativeMatrixGreen[ currentSrcColInt ],
145-
xDerivativeMatrixBlue[ currentSrcColInt ], xDerivativeMatrixAlpha[ currentSrcColInt ], xDerivativeMatrixRed[ currentSrcColInt + 1 ], xDerivativeMatrixGreen[ currentSrcColInt + 1 ],
146-
xDerivativeMatrixBlue[ currentSrcColInt + 1 ], xDerivativeMatrixAlpha[ currentSrcColInt + 1 ] ) );
148+
scanLine[x] = curveInterpolation( px1, px2, u, xDerivativeMatrixRed[ currentSrcColInt ], xDerivativeMatrixGreen[ currentSrcColInt ],
149+
xDerivativeMatrixBlue[ currentSrcColInt ], xDerivativeMatrixAlpha[ currentSrcColInt ], xDerivativeMatrixRed[ currentSrcColInt + 1 ], xDerivativeMatrixGreen[ currentSrcColInt + 1 ],
150+
xDerivativeMatrixBlue[ currentSrcColInt + 1 ], xDerivativeMatrixAlpha[ currentSrcColInt + 1 ] );
147151
}
148152
else if ( currentSrcRowInt >= ( srcImage.height() - 1 ) )
149153
{
150154
int idx = ( srcImage.height() - 1 ) * srcImage.width() + currentSrcColInt;
151155
px1 = srcImage.pixel( currentSrcColInt, srcImage.height() - 1 );
152156
px2 = srcImage.pixel( currentSrcColInt + 1, srcImage.height() - 1 );
153-
dstImage.setPixel( j, i, curveInterpolation( px1, px2, u, xDerivativeMatrixRed[ idx ], xDerivativeMatrixGreen[ idx ], xDerivativeMatrixBlue[idx],
154-
xDerivativeMatrixAlpha[idx], xDerivativeMatrixRed[ idx + 1 ], xDerivativeMatrixGreen[ idx + 1 ], xDerivativeMatrixBlue[idx + 1],
155-
xDerivativeMatrixAlpha[idx + 1] ) );
157+
scanLine[x] = curveInterpolation( px1, px2, u, xDerivativeMatrixRed[ idx ], xDerivativeMatrixGreen[ idx ], xDerivativeMatrixBlue[idx],
158+
xDerivativeMatrixAlpha[idx], xDerivativeMatrixRed[ idx + 1 ], xDerivativeMatrixGreen[ idx + 1 ], xDerivativeMatrixBlue[idx + 1],
159+
xDerivativeMatrixAlpha[idx + 1] );
156160
}
157161
else if ( currentSrcColInt < 0 )
158162
{
159163
int idx1 = currentSrcRowInt * srcImage.width();
160164
int idx2 = idx1 + srcImage.width();
161165
px1 = srcImage.pixel( 0, currentSrcRowInt );
162166
px2 = srcImage.pixel( 0, currentSrcRowInt + 1 );
163-
dstImage.setPixel( j, i, curveInterpolation( px1, px2, v, yDerivativeMatrixRed[ idx1 ], yDerivativeMatrixGreen[ idx1 ], yDerivativeMatrixBlue[ idx1],
164-
yDerivativeMatrixAlpha[ idx1], yDerivativeMatrixRed[ idx2 ], yDerivativeMatrixGreen[ idx2 ], yDerivativeMatrixBlue[ idx2],
165-
yDerivativeMatrixAlpha[ idx2] ) );
167+
scanLine[x] = curveInterpolation( px1, px2, v, yDerivativeMatrixRed[ idx1 ], yDerivativeMatrixGreen[ idx1 ], yDerivativeMatrixBlue[ idx1],
168+
yDerivativeMatrixAlpha[ idx1], yDerivativeMatrixRed[ idx2 ], yDerivativeMatrixGreen[ idx2 ], yDerivativeMatrixBlue[ idx2],
169+
yDerivativeMatrixAlpha[ idx2] );
166170
}
167171
else if ( currentSrcColInt >= ( srcImage.width() - 1 ) )
168172
{
169173
int idx1 = currentSrcRowInt * srcImage.width() + srcImage.width() - 1;
170174
int idx2 = idx1 + srcImage.width();
171175
px1 = srcImage.pixel( srcImage.width() - 1, currentSrcRowInt );
172176
px2 = srcImage.pixel( srcImage.width() - 1, currentSrcRowInt + 1 );
173-
dstImage.setPixel( j, i, curveInterpolation( px1, px2, v, yDerivativeMatrixRed[ idx1 ], yDerivativeMatrixGreen[ idx1 ], yDerivativeMatrixBlue[ idx1],
174-
yDerivativeMatrixAlpha[ idx1], yDerivativeMatrixRed[ idx2 ], yDerivativeMatrixGreen[ idx2 ], yDerivativeMatrixBlue[ idx2],
175-
yDerivativeMatrixAlpha[ idx2] ) );
177+
scanLine[x] = curveInterpolation( px1, px2, v, yDerivativeMatrixRed[ idx1 ], yDerivativeMatrixGreen[ idx1 ], yDerivativeMatrixBlue[ idx1],
178+
yDerivativeMatrixAlpha[ idx1], yDerivativeMatrixRed[ idx2 ], yDerivativeMatrixGreen[ idx2 ], yDerivativeMatrixBlue[ idx2],
179+
yDerivativeMatrixAlpha[ idx2] );
176180
}
177181
currentSrcCol += nSrcPerDstX;
178182
continue;
@@ -187,82 +191,83 @@ void QgsCubicRasterResampler::resample( const QImage& srcImage, QImage& dstImage
187191
}
188192

189193
//bernstein polynomials
190-
bp0u = calcBernsteinPoly( 3, 0, u ); bp1u = calcBernsteinPoly( 3, 1, u );
191-
bp2u = calcBernsteinPoly( 3, 2, u ); bp3u = calcBernsteinPoly( 3, 3, u );
192-
bp0v = calcBernsteinPoly( 3, 0, v ); bp1v = calcBernsteinPoly( 3, 1, v );
193-
bp2v = calcBernsteinPoly( 3, 2, v ); bp3v = calcBernsteinPoly( 3, 3, v );
194+
bp0u = calcBernsteinPolyN3( 0, u ); bp1u = calcBernsteinPolyN3( 1, u );
195+
bp2u = calcBernsteinPolyN3( 2, u ); bp3u = calcBernsteinPolyN3( 3, u );
196+
bp0v = calcBernsteinPolyN3( 0, v ); bp1v = calcBernsteinPolyN3( 1, v );
197+
bp2v = calcBernsteinPolyN3( 2, v ); bp3v = calcBernsteinPolyN3( 3, v );
194198

195199
//then calculate value based on bernstein form of Bezier patch
196200
//todo: move into function
197-
r = bp0u * bp0v * cRed00 +
198-
bp1u * bp0v * cRed10 +
199-
bp2u * bp0v * cRed20 +
200-
bp3u * bp0v * cRed30 +
201-
bp0u * bp1v * cRed01 +
202-
bp1u * bp1v * cRed11 +
203-
bp2u * bp1v * cRed21 +
204-
bp3u * bp1v * cRed31 +
205-
bp0u * bp2v * cRed02 +
206-
bp1u * bp2v * cRed12 +
207-
bp2u * bp2v * cRed22 +
208-
bp3u * bp2v * cRed32 +
209-
bp0u * bp3v * cRed03 +
210-
bp1u * bp3v * cRed13 +
211-
bp2u * bp3v * cRed23 +
212-
bp3u * bp3v * cRed33;
213-
214-
g = bp0u * bp0v * cGreen00 +
215-
bp1u * bp0v * cGreen10 +
216-
bp2u * bp0v * cGreen20 +
217-
bp3u * bp0v * cGreen30 +
218-
bp0u * bp1v * cGreen01 +
219-
bp1u * bp1v * cGreen11 +
220-
bp2u * bp1v * cGreen21 +
221-
bp3u * bp1v * cGreen31 +
222-
bp0u * bp2v * cGreen02 +
223-
bp1u * bp2v * cGreen12 +
224-
bp2u * bp2v * cGreen22 +
225-
bp3u * bp2v * cGreen32 +
226-
bp0u * bp3v * cGreen03 +
227-
bp1u * bp3v * cGreen13 +
228-
bp2u * bp3v * cGreen23 +
229-
bp3u * bp3v * cGreen33;
230-
231-
b = bp0u * bp0v * cBlue00 +
232-
bp1u * bp0v * cBlue10 +
233-
bp2u * bp0v * cBlue20 +
234-
bp3u * bp0v * cBlue30 +
235-
bp0u * bp1v * cBlue01 +
236-
bp1u * bp1v * cBlue11 +
237-
bp2u * bp1v * cBlue21 +
238-
bp3u * bp1v * cBlue31 +
239-
bp0u * bp2v * cBlue02 +
240-
bp1u * bp2v * cBlue12 +
241-
bp2u * bp2v * cBlue22 +
242-
bp3u * bp2v * cBlue32 +
243-
bp0u * bp3v * cBlue03 +
244-
bp1u * bp3v * cBlue13 +
245-
bp2u * bp3v * cBlue23 +
246-
bp3u * bp3v * cBlue33;
247-
248-
a = bp0u * bp0v * cAlpha00 +
249-
bp1u * bp0v * cAlpha10 +
250-
bp2u * bp0v * cAlpha20 +
251-
bp3u * bp0v * cAlpha30 +
252-
bp0u * bp1v * cAlpha01 +
253-
bp1u * bp1v * cAlpha11 +
254-
bp2u * bp1v * cAlpha21 +
255-
bp3u * bp1v * cAlpha31 +
256-
bp0u * bp2v * cAlpha02 +
257-
bp1u * bp2v * cAlpha12 +
258-
bp2u * bp2v * cAlpha22 +
259-
bp3u * bp2v * cAlpha32 +
260-
bp0u * bp3v * cAlpha03 +
261-
bp1u * bp3v * cAlpha13 +
262-
bp2u * bp3v * cAlpha23 +
263-
bp3u * bp3v * cAlpha33;
264-
265-
dstImage.setPixel( j, i, qRgba( r, g, b, a ) );
201+
int r = bp0u * bp0v * cRed00 +
202+
bp1u * bp0v * cRed10 +
203+
bp2u * bp0v * cRed20 +
204+
bp3u * bp0v * cRed30 +
205+
bp0u * bp1v * cRed01 +
206+
bp1u * bp1v * cRed11 +
207+
bp2u * bp1v * cRed21 +
208+
bp3u * bp1v * cRed31 +
209+
bp0u * bp2v * cRed02 +
210+
bp1u * bp2v * cRed12 +
211+
bp2u * bp2v * cRed22 +
212+
bp3u * bp2v * cRed32 +
213+
bp0u * bp3v * cRed03 +
214+
bp1u * bp3v * cRed13 +
215+
bp2u * bp3v * cRed23 +
216+
bp3u * bp3v * cRed33;
217+
218+
int g = bp0u * bp0v * cGreen00 +
219+
bp1u * bp0v * cGreen10 +
220+
bp2u * bp0v * cGreen20 +
221+
bp3u * bp0v * cGreen30 +
222+
bp0u * bp1v * cGreen01 +
223+
bp1u * bp1v * cGreen11 +
224+
bp2u * bp1v * cGreen21 +
225+
bp3u * bp1v * cGreen31 +
226+
bp0u * bp2v * cGreen02 +
227+
bp1u * bp2v * cGreen12 +
228+
bp2u * bp2v * cGreen22 +
229+
bp3u * bp2v * cGreen32 +
230+
bp0u * bp3v * cGreen03 +
231+
bp1u * bp3v * cGreen13 +
232+
bp2u * bp3v * cGreen23 +
233+
bp3u * bp3v * cGreen33;
234+
235+
int b = bp0u * bp0v * cBlue00 +
236+
bp1u * bp0v * cBlue10 +
237+
bp2u * bp0v * cBlue20 +
238+
bp3u * bp0v * cBlue30 +
239+
bp0u * bp1v * cBlue01 +
240+
bp1u * bp1v * cBlue11 +
241+
bp2u * bp1v * cBlue21 +
242+
bp3u * bp1v * cBlue31 +
243+
bp0u * bp2v * cBlue02 +
244+
bp1u * bp2v * cBlue12 +
245+
bp2u * bp2v * cBlue22 +
246+
bp3u * bp2v * cBlue32 +
247+
bp0u * bp3v * cBlue03 +
248+
bp1u * bp3v * cBlue13 +
249+
bp2u * bp3v * cBlue23 +
250+
bp3u * bp3v * cBlue33;
251+
252+
int a = bp0u * bp0v * cAlpha00 +
253+
bp1u * bp0v * cAlpha10 +
254+
bp2u * bp0v * cAlpha20 +
255+
bp3u * bp0v * cAlpha30 +
256+
bp0u * bp1v * cAlpha01 +
257+
bp1u * bp1v * cAlpha11 +
258+
bp2u * bp1v * cAlpha21 +
259+
bp3u * bp1v * cAlpha31 +
260+
bp0u * bp2v * cAlpha02 +
261+
bp1u * bp2v * cAlpha12 +
262+
bp2u * bp2v * cAlpha22 +
263+
bp3u * bp2v * cAlpha32 +
264+
bp0u * bp3v * cAlpha03 +
265+
bp1u * bp3v * cAlpha13 +
266+
bp2u * bp3v * cAlpha23 +
267+
bp3u * bp3v * cAlpha33;
268+
269+
scanLine[x] = createPremultipliedColor( r, g, b, a );
270+
266271
lastSrcColInt = currentSrcColInt;
267272
currentSrcCol += nSrcPerDstX;
268273
}
@@ -291,15 +296,15 @@ void QgsCubicRasterResampler::xDerivativeMatrix( int nCols, int nRows, double* m
291296
double val = 0;
292297
int index = 0;
293298

294-
for ( int i = 0; i < nRows; ++i )
299+
for ( int y = 0; y < nRows; ++y )
295300
{
296-
for ( int j = 0; j < nCols; ++j )
301+
for ( int x = 0; x < nCols; ++x )
297302
{
298-
if ( j < 1 )
303+
if ( x == 0 )
299304
{
300305
val = colorMatrix[index + 1] - colorMatrix[index];
301306
}
302-
else if ( j == ( nCols - 1 ) )
307+
else if ( x == ( nCols - 1 ) )
303308
{
304309
val = colorMatrix[index] - colorMatrix[ index - 1 ];
305310
}
@@ -318,15 +323,15 @@ void QgsCubicRasterResampler::yDerivativeMatrix( int nCols, int nRows, double* m
318323
double val = 0;
319324
int index = 0;
320325

321-
for ( int i = 0; i < nRows; ++i )
326+
for ( int y = 0; y < nRows; ++y )
322327
{
323-
for ( int j = 0; j < nCols; ++j )
328+
for ( int x = 0; x < nCols; ++x )
324329
{
325-
if ( i == 0 )
330+
if ( y == 0 )
326331
{
327332
val = colorMatrix[ index + nCols ] - colorMatrix[ index ];
328333
}
329-
else if ( i == ( nRows - 1 ) )
334+
else if ( y == ( nRows - 1 ) )
330335
{
331336
val = colorMatrix[ index ] - colorMatrix[ index - nCols ];
332337
}
@@ -399,78 +404,49 @@ QRgb QgsCubicRasterResampler::curveInterpolation( QRgb pt1, QRgb pt2, double t,
399404
double p0a = qAlpha( pt1 ); double p1a = p0a + 0.333 * d1alpha; double p3a = qAlpha( pt2 ); double p2a = p3a - 0.333 * d2alpha;
400405

401406
//bernstein polynomials
402-
double bp0 = calcBernsteinPoly( 3, 0, t );
403-
double bp1 = calcBernsteinPoly( 3, 1, t );
404-
double bp2 = calcBernsteinPoly( 3, 2, t );
405-
double bp3 = calcBernsteinPoly( 3, 3, t );
407+
double bp0 = calcBernsteinPolyN3( 0, t );
408+
double bp1 = calcBernsteinPolyN3( 1, t );
409+
double bp2 = calcBernsteinPolyN3( 2, t );
410+
double bp3 = calcBernsteinPolyN3( 3, t );
406411

407412
int red = bp0 * p0r + bp1 * p1r + bp2 * p2r + bp3 * p3r;
408413
int green = bp0 * p0g + bp1 * p1g + bp2 * p2g + bp3 * p3g;
409414
int blue = bp0 * p0b + bp1 * p1b + bp2 * p2b + bp3 * p3b;
410415
int alpha = bp0 * p0a + bp1 * p1a + bp2 * p2a + bp3 * p3a;
411416

412-
return qRgba( red, green, blue, alpha );
417+
return createPremultipliedColor( red, green, blue, alpha );
413418
}
414419

415-
double QgsCubicRasterResampler::calcBernsteinPoly( int n, int i, double t )
420+
double QgsCubicRasterResampler::calcBernsteinPolyN3( int i, double t )
416421
{
417422
if ( i < 0 )
418423
{
419424
return 0;
420425
}
421426

422-
return lower( n, i )*power( t, i )*power(( 1 - t ), ( n - i ) );
427+
return lowerN3( i ) * qPow( t, i ) * qPow(( 1 - t ), ( 3 - i ) );
423428
}
424429

425-
int QgsCubicRasterResampler::lower( int n, int i )
430+
inline int QgsCubicRasterResampler::lowerN3( int i )
426431
{
427-
if ( i >= 0 && i <= n )
432+
switch ( i )
428433
{
429-
return faculty( n ) / ( faculty( i )*faculty( n - i ) );
430-
}
431-
else
432-
{
433-
return 0;
434+
case 0:
435+
case 3:
436+
return 1;
437+
case 1:
438+
case 2:
439+
return 3;
440+
default:
441+
return 0;
434442
}
435443
}
436444

437-
double QgsCubicRasterResampler::power( double a, int b )
445+
QRgb QgsCubicRasterResampler::createPremultipliedColor( const int r, const int g, const int b, const int a )
438446
{
439-
if ( b == 0 )
440-
{
441-
return 1;
442-
}
443-
double tmp = a;
444-
for ( int i = 2; i <= qAbs(( double )b ); i++ )
445-
{
446-
447-
a *= tmp;
448-
}
449-
if ( b > 0 )
450-
{
451-
return a;
452-
}
453-
else
454-
{
455-
return ( 1.0 / a );
456-
}
457-
}
458-
459-
int QgsCubicRasterResampler::faculty( int n )
460-
{
461-
if ( n < 0 )//Is faculty also defined for negative integers?
462-
{
463-
return 0;
464-
}
465-
int i;
466-
int result = n;
467-
468-
if ( n == 0 || n == 1 )
469-
{return 1;}//faculty of 0 is 1!
470-
471-
for ( i = n - 1; i >= 2; i-- )
472-
{
473-
result *= i;
474-
}
475-
return result;
447+
int maxComponentBounds = qBound( 0, a, 255 );
448+
return qRgba( qBound( 0, r, maxComponentBounds ),
449+
qBound( 0, g, maxComponentBounds ),
450+
qBound( 0, b, maxComponentBounds ),
451+
a );
476452
}

‎src/core/raster/qgscubicrasterresampler.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ class CORE_EXPORT QgsCubicRasterResampler: public QgsRasterResampler
4646
QRgb curveInterpolation( QRgb pt1, QRgb pt2, double t, double d1red, double d1green, double d1blue, double d1alpha, double d2red, double d2green,
4747
double d2blue, double d2alpha );
4848

49-
static double calcBernsteinPoly( int n, int i, double t );
50-
static int lower( int n, int i );
51-
static double power( double a, int b );//calculates a power b
52-
static int faculty( int n );
49+
static inline double calcBernsteinPolyN3( int i, double t );
50+
static inline int lowerN3( int i );
51+
52+
//creates a QRgb by applying bounds checks
53+
static inline QRgb createPremultipliedColor( const int r, const int g, const int b, const int a );
5354

5455
//control points
5556

@@ -65,6 +66,8 @@ class CORE_EXPORT QgsCubicRasterResampler: public QgsRasterResampler
6566
//alpha
6667
double cAlpha00; double cAlpha10; double cAlpha20; double cAlpha30; double cAlpha01; double cAlpha11; double cAlpha21; double cAlpha31;
6768
double cAlpha02; double cAlpha12; double cAlpha22; double cAlpha32; double cAlpha03; double cAlpha13; double cAlpha23; double cAlpha33;
69+
70+
6871
};
6972

7073
#endif // QGSCUBICRASTERRESAMPLER_H

0 commit comments

Comments
 (0)
Please sign in to comment.