int x = currentIPPosition; // TODO + area.getXOffset();
int y = currentBPPosition;
String url = ImageFactory.getURL(pUrl);
ImageFactory fact = ImageFactory.getInstance();
FopImage fopimage = fact.getImage(url, userAgent);
if (fopimage == null) {
return;
}
if (!fopimage.load(FopImage.DIMENSIONS)) {
return;
}
int w = fopimage.getWidth();
int h = fopimage.getHeight();
String mime = fopimage.getMimeType();
if ("text/xml".equals(mime)) {
if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
return;
}
Document doc = ((XMLImage) fopimage).getDocument();
String ns = ((XMLImage) fopimage).getNameSpace();
renderDocument(doc, ns, pos);
} else if ("image/svg+xml".equals(mime)) {
if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
return;
}
Document doc = ((XMLImage) fopimage).getDocument();
String ns = ((XMLImage) fopimage).getNameSpace();
renderDocument(doc, ns, pos);
} else if ("image/eps".equals(mime)) {
log.warn("EPS images are not supported by this renderer");
currentBPPosition += (h * 1000);
} else if ("image/jpeg".equals(mime)) {
if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
return;
}
// TODO Load JPEGs rather through fopimage.load(FopImage.BITMAP),
// but JpegImage will need to be extended for that
// url = url.substring(7);
// url = "C:/eclipse/myWorkbenches/fop4/xml-fop/examples/fo" + url;
java.awt.Image awtImage = new javax.swing.ImageIcon(url).getImage();
state.getGraph().drawImage(awtImage,
(int)(x / 1000f), (int)(y / 1000f),
(int)(pos.getWidth() / 1000f), (int)(pos.getHeight() / 1000f), null);
currentBPPosition += (h * 1000);
} else {
if (!fopimage.load(FopImage.BITMAP)) {
log.warn("Loading of bitmap failed: " + url);
return;
}
byte[] raw = fopimage.getBitmaps();
// TODO Hardcoded color and sample models, FIX ME!
ColorModel cm = new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB),
new int[] {8, 8, 8},