From 6f0eeb7071858d66d9d44ef677f336a0edeed2ab Mon Sep 17 00:00:00 2001 From: eschaeffer Date: Tue, 23 May 2000 09:14:38 +0000 Subject: [PATCH] changes in fo:inline-graphic git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193368 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/InlineGraphic.java | 71 +++++++++++++------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/src/org/apache/fop/fo/flow/InlineGraphic.java b/src/org/apache/fop/fo/flow/InlineGraphic.java index a339d037d..b6542f170 100644 --- a/src/org/apache/fop/fo/flow/InlineGraphic.java +++ b/src/org/apache/fop/fo/flow/InlineGraphic.java @@ -48,6 +48,7 @@ Software Foundation, please see . */ +/* Modified by Eric SCHAEFFER */ package org.apache.fop.fo.flow; @@ -63,6 +64,8 @@ import org.apache.fop.image.*; // Java import java.util.Enumeration; import java.util.Hashtable; +import java.net.URL; +import java.net.MalformedURLException; public class InlineGraphic extends FObj { @@ -154,28 +157,52 @@ public class InlineGraphic extends FObj { this.marker = 0; } - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - - FopImage img = new GifJpegImage(href, 0, 0, width, height); - - this.imageArea = new ImageArea(fs, - img, - area.getAllocationWidth(), - img.getWidth(), - img.getHeight(), - startIndent, endIndent, - align); - - imageArea.start(); - imageArea.end(); - area.addChild(imageArea); - area.increaseHeight(imageArea.getHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); + try { + FopImage img = FopImageFactory.Make(href); + // if width / height needs to be computed + if ((width == 0) || (height == 0)) { + // aspect ratio + double imgWidth = img.getWidth(); + double imgHeight = img.getHeight(); + if ((width == 0) && (height == 0)) { + width = (int) (imgWidth / 2d * 1000d); + height = (int) (imgHeight / 2d * 1000d); + } else if (height == 0) { + height = (int) (imgHeight / imgWidth * ((double) width)); + } else if (width == 0) { + width = (int) (imgWidth / imgHeight * ((double) height)); + } + } + this.imageArea = new ImageArea( + fs, + img, + area.getAllocationWidth(), + width, + height, + startIndent, + endIndent, + align + ); + + if ((spaceBefore != 0) && (this.marker == 0)) { + area.addDisplaySpace(spaceBefore); + } + + imageArea.start(); + imageArea.end(); + area.addChild(imageArea); + area.increaseHeight(imageArea.getHeight()); + + if (spaceAfter != 0) { + area.addDisplaySpace(spaceAfter); + } + + } catch (MalformedURLException urlex) { + // bad URL +System.err.println("Error while creating area : " + urlex.getMessage()); + } catch (FopImageException imgex) { + // image error +System.err.println("Error while creating area : " + imgex.getMessage()); } if (area instanceof BlockArea) { -- 2.39.5