Index: trunk/Ohana/src/kapa2/src/PaintOverlay.c
===================================================================
--- trunk/Ohana/src/kapa2/src/PaintOverlay.c	(revision 17119)
+++ trunk/Ohana/src/kapa2/src/PaintOverlay.c	(revision 17120)
@@ -5,6 +5,6 @@
   int i;
   int dX, dY, dx, dy;
-  int x, y, X, Y, Xmin, Ymin, Xmax, Ymax, Xrange, Yrange;
-  double t, expand, X0, Y0;
+  int x, y, Xmin, Ymin, Xmax, Ymax, Xrange, Yrange;
+  double t, expand, X, Y;
  
   XSetForeground (graphic[0].display, graphic[0].gc, image[0].overlay[N].color);
@@ -12,11 +12,9 @@
   expand = 1.0;
   if (image[0].picture.expand > 0) {
-    expand = 1 / (1.0*image[0].picture.expand);
+    expand = image[0].picture.expand;
   }
   if (image[0].picture.expand < 0) {
-    expand = fabs((double)image[0].picture.expand);
+    expand = 1.0 / fabs((double)image[0].picture.expand);
   }
-
-  Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture);
 
   Xmin = image[0].picture.x;
@@ -28,12 +26,14 @@
 
   for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
-    X  = image[0].overlay[N].objects[i].x/expand + X0;
-    Y =  image[0].overlay[N].objects[i].y/expand + Y0;
-    dX = image[0].overlay[N].objects[i].dx/expand;
-    dY = image[0].overlay[N].objects[i].dy/expand;
-    if ((X + dX < Xmin) || (X - dX > Xmax) ||
-	(Y + dY < Ymin) || (Y - dY > Ymax)) {
-      continue;
-    }
+    Image_to_Screen (&X, &Y, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].picture);
+    dX = image[0].overlay[N].objects[i].dx * expand;
+    dY = image[0].overlay[N].objects[i].dy * expand;
+    if (image[0].picture.flipx) dX *= -1;
+    if (image[0].picture.flipy) dY *= -1;
+
+    if (X + dX < Xmin) continue;
+    if (X - dX > Xmax) continue;
+    if (Y + dY < Ymin) continue; 
+    if (Y - dY > Ymax);
 
     /* for a LINE, (x, y) is the start, (dx, dy) is the distance to end
