mirror of https://github.com/adamdruppe/arsd.git
Refactor component/channel loop of image scaler
This commit is contained in:
parent
539480a2fa
commit
2804f426c4
|
@ -3092,7 +3092,7 @@ private void scaleToImpl(ScalingFilter filter)(const Pixmap source, Pixmap targe
|
|||
];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
auto dst = PixmapScannerRW(target);
|
||||
|
||||
|
@ -3170,10 +3170,8 @@ private void scaleToImpl(ScalingFilter filter)(const Pixmap source, Pixmap targe
|
|||
multi,
|
||||
}
|
||||
|
||||
foreach (immutable ib, ref c; pxInt.components) {
|
||||
|
||||
// ======== Interpolate X ========
|
||||
auto sampleX(SamplingMode mode)() {
|
||||
auto sampleX(SamplingMode mode)(const size_t ib) {
|
||||
pragma(inline, true);
|
||||
|
||||
static if (mode == SamplingMode.multi) {
|
||||
|
@ -3380,13 +3378,18 @@ private void scaleToImpl(ScalingFilter filter)(const Pixmap source, Pixmap targe
|
|||
|
||||
// ======== Interpolate Y ========
|
||||
static if (directionY == none) {
|
||||
c = clamp255(sampleX!(SamplingMode.single)());
|
||||
foreach (immutable ib, ref c; pxInt.components) {
|
||||
c = clamp255(sampleX!(SamplingMode.single)(ib));
|
||||
}
|
||||
}
|
||||
static if (directionY == down) {
|
||||
c = clamp255(sampleX!(SamplingMode.multi)());
|
||||
foreach (immutable ib, ref c; pxInt.components) {
|
||||
c = clamp255(sampleX!(SamplingMode.multi)(ib));
|
||||
}
|
||||
}
|
||||
static if (directionY == up) {
|
||||
const xSums = sampleX!(SamplingMode.dual)();
|
||||
foreach (immutable ib, ref c; pxInt.components) {
|
||||
const xSums = sampleX!(SamplingMode.dual)(ib);
|
||||
|
||||
ulong ySum = 0;
|
||||
ySum += (xSums[idxT] * weightsY[idxT]);
|
||||
|
|
Loading…
Reference in New Issue