diff options
author | eschaeffer <eschaeffer@unknown> | 2000-11-20 16:36:42 +0000 |
---|---|---|
committer | eschaeffer <eschaeffer@unknown> | 2000-11-20 16:36:42 +0000 |
commit | 54aba1a30fe6d7bf18edd7d6be0ae05221a87769 (patch) | |
tree | 5099a1d1f8c79e62d812a7594ebfc83abf89a7e5 | |
parent | f9c70dded6430f84fda692dae10737f2a4eef624 (diff) | |
download | xmlgraphics-fop-54aba1a30fe6d7bf18edd7d6be0ae05221a87769.tar.gz xmlgraphics-fop-54aba1a30fe6d7bf18edd7d6be0ae05221a87769.zip |
Check if the image can fit in the area, and scale it if needed.
PR:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193828 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/org/apache/fop/fo/flow/ExternalGraphic.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index 53e28aa74..a6d2bcee9 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -181,6 +181,21 @@ public class ExternalGraphic extends FObj { //MessageHandler.errorln("DisplayGraphic: imgW=" + imgWidth + " imgH=" + imgHeight + " w=" + width + " h=" + height); } + // scale image if it doesn't fit in the area/page + // Need to be more tested... + double ratio = ((double) width) / ((double) height); + int areaWidth = area.getAllocationWidth(); + int areaHeight = area.getMaxHeight(); + if ((width > areaWidth) || (height > areaHeight)) { + if (width > height) { + width = areaWidth; + height = (int) (((double) width) / ratio); + } else { + height = areaHeight; + width = (int) (ratio * ((double) width)); + } + } + if (area.spaceLeft() < (height + spaceBefore)) { return new Status(Status.AREA_FULL_NONE); } |