Mercurial > hg > svgui
changeset 1220:2954e9952b78
Fix #1781 Running CQ Chromagram spits out stacks of "bin index out of range" warnings
author | Chris Cannam |
---|---|
date | Thu, 26 Jan 2017 10:41:50 +0000 |
parents | c06861dec245 |
children | eaab8bab3522 |
files | layer/Colour3DPlotLayer.cpp |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Mon Jan 16 10:00:19 2017 +0000 +++ b/layer/Colour3DPlotLayer.cpp Thu Jan 26 10:41:50 2017 +0000 @@ -761,11 +761,15 @@ getDisplayExtents(mn, mx); double h = v->getPaintHeight(); if (m_binScale == BinScale::Linear) { - bin = mn + ((h - y) * (mx - mn)) / h; + // Arrange that the first bin (mn) appears as the exact result + // for the first pixel (which is pixel h-1) and the first + // out-of-range bin (mx) would appear as the exact result for + // the first out-of-range pixel (which would be pixel -1) + bin = mn + ((h - y - 1) * (mx - mn)) / h; } else { double logmin = mn + 1, logmax = mx + 1; LogRange::mapRange(logmin, logmax); - bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; + bin = LogRange::unmap(logmin + ((h - y - 1) * (logmax - logmin)) / h) - 1; } return bin; }