From 70fed8c96297b3f0a97607a38bd60a8419b9aac7 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 7 Sep 2002 16:50:34 +0000 Subject: [PATCH] dont draw borders past the end of a texture --- src/Image.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Image.cc b/src/Image.cc index 4b27d495..2094c003 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -822,6 +822,8 @@ void BImage::bevel2(void) { void BImage::border(const BTexture &texture) { + if (width < 2 || height < 2) return; + register unsigned int i; int r = texture.borderColor().red(), g = texture.borderColor().green(), @@ -839,17 +841,19 @@ void BImage::border(const BTexture &texture) { *pb++ = b; } - // left and right lines (pr,pg,pb are already lined up) - for (i = 1; i < height - 1; ++i) { - *pr = r; - *pg = g; - *pb = b; - pr += width - 1; - pg += width - 1; - pb += width - 1; - *pr++ = r; - *pg++ = g; - *pb++ = b; + if (height > 2) { + // left and right lines (pr,pg,pb are already lined up) + for (i = 1; i < height - 1; ++i) { + *pr = r; + *pg = g; + *pb = b; + pr += width - 1; + pg += width - 1; + pb += width - 1; + *pr++ = r; + *pg++ = g; + *pb++ = b; + } } // bottom line (pr,pg,pb are already lined up) -- 2.45.2