# HG changeset patch # User Chris Cannam # Date 1485427310 0 # Node ID 2954e9952b78004a53d4e8cb9acd70470322c80a # Parent c06861dec2452e4b18e596ee2485c909a42151b3 Fix #1781 Running CQ Chromagram spits out stacks of "bin index out of range" warnings diff -r c06861dec245 -r 2954e9952b78 layer/Colour3DPlotLayer.cpp --- 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; }