]> Dogcows Code - chaz/openbox/commitdiff
dont draw borders past the end of a texture
authorDana Jansens <danakj@orodu.net>
Sat, 7 Sep 2002 16:50:34 +0000 (16:50 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 7 Sep 2002 16:50:34 +0000 (16:50 +0000)
src/Image.cc

index 4b27d49522bbc3c3c4eaeac1b8932fd9120b8b59..2094c00382995ca82f17a66a691bd5c10e0af50b 100644 (file)
@@ -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)
This page took 0.031981 seconds and 4 git commands to generate.