]> granicus.if.org Git - graphviz/commitdiff
Fix html table code so that images are kept at their natural size.
authorerg <devnull@localhost>
Fri, 16 Mar 2007 20:40:47 +0000 (20:40 +0000)
committererg <devnull@localhost>
Fri, 16 Mar 2007 20:40:47 +0000 (20:40 +0000)
lib/common/htmltable.c

index 6ca5da0f033fcb1ce5013d79a0cd6200811e98fe..5a8569f10600dbffcb25d94a88f5f49e8d9fbd03 100644 (file)
@@ -1191,9 +1191,35 @@ void sizeArray(htmltbl_t * tbl)
 
 static void pos_html_tbl(htmltbl_t *, box, int);  /* forward declaration */
 
+/* pos_html_img:
+ * Place image in cell. 
+ * If enough space, center; if not, fill.
+ * TODO: Allow fill even if plenty of space
+ *       Allow user control of alignment
+ */
 static void pos_html_img(htmlimg_t * cp, box pos)
 {
-    cp->box = pos;
+    int cw = pos.UR.x - pos.LL.x;
+    int ch = pos.UR.y - pos.LL.y;
+    int delx = cw - cp->box.UR.x;
+    int dely = ch - cp->box.UR.y;
+
+    if (delx > 0) {
+       cp->box.LL.x = pos.LL.x + delx/2;
+       cp->box.UR.x += cp->box.LL.x;
+    }
+    else {
+       cp->box.LL.x = pos.LL.x;
+       cp->box.UR.x = pos.UR.x;
+    }
+    if (dely > 0) {
+       cp->box.LL.y = pos.LL.y + dely/2;
+       cp->box.UR.y += cp->box.LL.y;
+    }
+    else {
+       cp->box.LL.y = pos.LL.y;
+       cp->box.UR.y = pos.UR.y;
+    }
 }
 
 /* pos_html_txt: