Skip to content

Commit 3aacd5f

Browse files
authored
Add files via upload
1 parent 6effde5 commit 3aacd5f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

nQuantCpp/GilbertCurve.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ namespace Peano
244244

245245
if (m_hasAlpha && m_saliencies == nullptr) {
246246
if (abs(error[j]) >= (ditherMax * M_E * M_PI) || error[3] < 0)
247-
error[j] = (float)tanh(error[j] / maxErr * 20) * (ditherMax - 1);
247+
error[j] = tanh(error[j] / maxErr * 20) * (ditherMax - 1);
248248
continue;
249249
}
250250

251-
error[j] = (float)tanh(error[j] / maxErr * 20) * (ditherMax - 1);
251+
error[j] = tanh(error[j] / maxErr * 20) * (ditherMax - 1);
252252
}
253253

254254
if (sortedByYDiff && m_saliencies == nullptr && abs(error[j]) >= DITHER_MAX)
@@ -384,6 +384,8 @@ namespace Peano
384384
auto edge = m_hasAlpha ? 1 : exp(weight) - .25;
385385
if (saliencies != nullptr && (m_hasAlpha || (sortedByYDiff && weight < .03)))
386386
ditherMax = (BYTE)(DITHER_MAX / weight);
387+
else if (m_hasAlpha)
388+
ditherMax = (BYTE)(DITHER_MAX / _sqrt(weight));
387389
else {
388390
auto deviation = !m_hasAlpha && weight > .0025 ? -.25 : 1;
389391
ditherMax = (m_hasAlpha || DITHER_MAX > 9) ? (BYTE)sqr(_sqrt(DITHER_MAX) + edge * deviation) : (BYTE)(DITHER_MAX * (saliencies != nullptr ? 2 : M_E));

0 commit comments

Comments
 (0)