mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 12:05:47 +01:00
Fix small bug in downsampling that causes artifacts
This commit is contained in:
parent
1093447055
commit
e9a9988a56
@ -52,6 +52,7 @@
|
||||
|
||||
#include "Image.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
@ -62,6 +63,11 @@
|
||||
#include "Core/include/Image.h"
|
||||
#include "IO/include/ImageFile.h"
|
||||
|
||||
template <typename T>
|
||||
inline T Clamp(const T &v, const T &a, const T &b) {
|
||||
return ::std::min(::std::max(a, v), b);
|
||||
}
|
||||
|
||||
static float ConvertChannelToFloat(uint8 channel, uint8 bitDepth) {
|
||||
float denominator = static_cast<float>((1 << bitDepth) - 1);
|
||||
return static_cast<float>(channel) / denominator;
|
||||
@ -346,7 +352,7 @@ void Image::ContentAwareDownscale(uint32 xtimes, uint32 ytimes,
|
||||
Iysq * Iyy[c][idx]) / denom;
|
||||
}
|
||||
float scale = static_cast<float>((1 << bitDepth[c]) - 1);
|
||||
result.Component(c) = static_cast<uint8>((I0 + 0.25*It) * scale + 0.5);
|
||||
result.Component(c) = static_cast<uint8>(Clamp(I0 + 0.25f*It, 0.0f, 1.0f) * scale + 0.5);
|
||||
}
|
||||
|
||||
downscaledPixels[j * newHeight + i] = result;
|
||||
|
Loading…
Reference in New Issue
Block a user