From: erg Date: Fri, 16 Mar 2007 20:40:47 +0000 (+0000) Subject: Fix html table code so that images are kept at their natural size. X-Git-Tag: LAST_LIBGRAPH~32^2~5620 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91f68ff082cd1045fe6b7c27c458f77046d10f6a;p=graphviz Fix html table code so that images are kept at their natural size. --- diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index 6ca5da0f0..5a8569f10 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -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: