GRAPHICS: Add a Normal5x scaler
This commit is contained in:
parent
4500cc8451
commit
909be8a933
1 changed files with 58 additions and 1 deletions
|
@ -28,6 +28,7 @@ NormalPlugin::NormalPlugin() {
|
|||
_factors.push_back(2);
|
||||
_factors.push_back(3);
|
||||
_factors.push_back(4);
|
||||
_factors.push_back(5);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -164,6 +165,56 @@ void Normal4x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit
|
|||
dstPtr += dstPitch4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trivial nearest-neighbor 5x scaler.
|
||||
*/
|
||||
template<typename Pixel>
|
||||
void Normal5x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
|
||||
int width, int height) {
|
||||
uint8 *r;
|
||||
const uint32 dstPitch2 = dstPitch * 2;
|
||||
const uint32 dstPitch3 = dstPitch * 3;
|
||||
const uint32 dstPitch4 = dstPitch * 4;
|
||||
const uint32 dstPitch5 = dstPitch * 5;
|
||||
int b = sizeof(Pixel);
|
||||
|
||||
assert(IS_ALIGNED(dstPtr, 2));
|
||||
while (height--) {
|
||||
r = dstPtr;
|
||||
for (int i = 0; i < width; ++i, r += b * 5) {
|
||||
Pixel color = *(((const Pixel *)srcPtr) + i);
|
||||
|
||||
*(Pixel *)(r + b * 0) = color;
|
||||
*(Pixel *)(r + b * 1) = color;
|
||||
*(Pixel *)(r + b * 2) = color;
|
||||
*(Pixel *)(r + b * 3) = color;
|
||||
*(Pixel *)(r + b * 4) = color;
|
||||
*(Pixel *)(r + b * 0 + dstPitch) = color;
|
||||
*(Pixel *)(r + b * 1 + dstPitch) = color;
|
||||
*(Pixel *)(r + b * 2 + dstPitch) = color;
|
||||
*(Pixel *)(r + b * 3 + dstPitch) = color;
|
||||
*(Pixel *)(r + b * 4 + dstPitch) = color;
|
||||
*(Pixel *)(r + b * 0 + dstPitch2) = color;
|
||||
*(Pixel *)(r + b * 1 + dstPitch2) = color;
|
||||
*(Pixel *)(r + b * 2 + dstPitch2) = color;
|
||||
*(Pixel *)(r + b * 3 + dstPitch2) = color;
|
||||
*(Pixel *)(r + b * 4 + dstPitch2) = color;
|
||||
*(Pixel *)(r + b * 0 + dstPitch3) = color;
|
||||
*(Pixel *)(r + b * 1 + dstPitch3) = color;
|
||||
*(Pixel *)(r + b * 2 + dstPitch3) = color;
|
||||
*(Pixel *)(r + b * 3 + dstPitch3) = color;
|
||||
*(Pixel *)(r + b * 4 + dstPitch3) = color;
|
||||
*(Pixel *)(r + b * 0 + dstPitch4) = color;
|
||||
*(Pixel *)(r + b * 1 + dstPitch4) = color;
|
||||
*(Pixel *)(r + b * 2 + dstPitch4) = color;
|
||||
*(Pixel *)(r + b * 3 + dstPitch4) = color;
|
||||
*(Pixel *)(r + b * 4 + dstPitch4) = color;
|
||||
}
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch5;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void NormalPlugin::scaleIntern(const uint8 *srcPtr, uint32 srcPitch,
|
||||
|
@ -184,6 +235,9 @@ void NormalPlugin::scaleIntern(const uint8 *srcPtr, uint32 srcPitch,
|
|||
case 4:
|
||||
Normal4x<uint16>(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
break;
|
||||
case 5:
|
||||
Normal5x<uint16>(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
assert(_format.bytesPerPixel == 4);
|
||||
|
@ -197,6 +251,9 @@ void NormalPlugin::scaleIntern(const uint8 *srcPtr, uint32 srcPitch,
|
|||
case 4:
|
||||
Normal4x<uint32>(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
break;
|
||||
case 5:
|
||||
Normal5x<uint32>(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -204,7 +261,7 @@ void NormalPlugin::scaleIntern(const uint8 *srcPtr, uint32 srcPitch,
|
|||
|
||||
uint NormalPlugin::increaseFactor() {
|
||||
#ifdef USE_SCALERS
|
||||
if (_factor < 4)
|
||||
if (_factor < 5)
|
||||
setFactor(_factor + 1);
|
||||
#endif
|
||||
return _factor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue