Commit 53fd2de9 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

backport commit #a0ea6361 from git/master to frameworks branch

CCBUGS: 333540
CCBUGS: 319383
CCBUGS: 345168
parent 5a9689d7
...@@ -1204,7 +1204,7 @@ void DImg::prepareSubPixelAccess() ...@@ -1204,7 +1204,7 @@ void DImg::prepareSubPixelAccess()
} }
else else
{ {
float d = sqrt(((float)i) / LANCZOS_TABLE_RES); float d = sqrt(((float)i) / LANCZOS_TABLE_RES);
lanczos_func [i] = (LANCZOS_DATA_TYPE)((LANCZOS_DATA_ONE * LANCZOS_SUPPORT * lanczos_func [i] = (LANCZOS_DATA_TYPE)((LANCZOS_DATA_ONE * LANCZOS_SUPPORT *
sin(M_PI * d) * sin((M_PI / LANCZOS_SUPPORT) * d)) / sin(M_PI * d) * sin((M_PI / LANCZOS_SUPPORT) * d)) /
(M_PI * M_PI * d * d)); (M_PI * M_PI * d * d));
...@@ -1264,7 +1264,7 @@ static inline int normalizeAndClamp(int norm, int sum, int max) ...@@ -1264,7 +1264,7 @@ static inline int normalizeAndClamp(int norm, int sum, int max)
DColor DImg::getSubPixelColor(float x, float y) const DColor DImg::getSubPixelColor(float x, float y) const
{ {
if (isNull() || x >= width() || y >= height()) if (isNull() || x < 0 || y < 0 || x >= width() || y >= height())
{ {
return DColor(); return DColor();
} }
...@@ -1301,16 +1301,15 @@ DColor DImg::getSubPixelColor(float x, float y) const ...@@ -1301,16 +1301,15 @@ DColor DImg::getSubPixelColor(float x, float y) const
for (xc = xs; xc <= xe; xc += 1.0, dx -= 1.0) for (xc = xs; xc <= xe; xc += 1.0, dx -= 1.0)
{ {
uchar* data = bits() + (int)(xs * bytesDepth()) + (int)(width() * ys * bytesDepth()); uchar* data = bits() + (int)(xs * bytesDepth()) + (int)(width() * ys * bytesDepth());
DColor src = DColor(data, sixteenBit()); DColor src = DColor(data, sixteenBit());
float d = dx * dx + dy * dy;
float d = dx * dx + dy * dy;
if (d >= LANCZOS_SUPPORT * LANCZOS_SUPPORT) if (d >= LANCZOS_SUPPORT * LANCZOS_SUPPORT)
{ {
continue; continue;
} }
d = lanczos_func [(int)(d * LANCZOS_TABLE_RES)]; d = lanczos_func [(int)(d * LANCZOS_TABLE_RES)];
norm += d; norm += d;
sumR += d * src.red(); sumR += d * src.red();
sumG += d * src.green(); sumG += d * src.green();
...@@ -1361,7 +1360,7 @@ DColor DImg::getSubPixelColor(float x, float y) const ...@@ -1361,7 +1360,7 @@ DColor DImg::getSubPixelColor(float x, float y) const
continue; continue;
} }
d = lanczos_func [(d * LANCZOS_TABLE_RES) >> 12]; d = lanczos_func [(d * LANCZOS_TABLE_RES) >> 12];
norm += d; norm += d;
sumR += d * src.red(); sumR += d * src.red();
sumG += d * src.green(); sumG += d * src.green();
...@@ -1381,6 +1380,16 @@ DColor DImg::getSubPixelColor(float x, float y) const ...@@ -1381,6 +1380,16 @@ DColor DImg::getSubPixelColor(float x, float y) const
DColor DImg::getSubPixelColorFast(float x, float y) const DColor DImg::getSubPixelColorFast(float x, float y) const
{ {
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
int xx = (int)x; int xx = (int)x;
int yy = (int)y; int yy = (int)y;
float d_x = x - (int)x; float d_x = x - (int)x;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment