From 32d3e0de76b90bea826cebb63365101d0590ddc5 Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Sun, 2 Apr 2017 10:07:12 -0700 Subject: [PATCH] Fixed rectangle style setting if segment has an incomplete last line --- atrcopy/segments.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/atrcopy/segments.py b/atrcopy/segments.py index a954de4..7750c19 100644 --- a/atrcopy/segments.py +++ b/atrcopy/segments.py @@ -753,7 +753,12 @@ class DefaultSegment(object): r = r2 - r1 c = c2 - c1 indexes = np.tile(np.arange(c), r) + np.repeat(np.arange(r) * bytes_per_row, c) + start - s[indexes] |= style_bits + + # Limit the indexes actually used to the size of the array, because + # if the region has an incomplete last line, the style setting + # would fail because it isn't be a perfect rectangle + clamped = indexes[np.where(np.less(indexes, len(self)))[0]] + s[clamped] |= style_bits def rects_to_ranges(self, rects, bytes_per_row): ranges = []