My first thought is that you are drawing an image that has more output columns than input, which would give you values for min
and max
(and therefore yMin
and yMax
) that are out of range. I would expect that the yMin
calculation would throw the exception in that case.
You should be clamping the yMin
and yMax
values to the size of the drawing area on the canvas, then adding the BORDER_WIDTH
offset before (or during) the call to g.DrawLine
.