* @param alignment horizontal alignment (constant from Element class)
* @return the height of the image
*/
private float addImage(LwgImage i, float left, float right, float extraHeight, int alignment) {
LwgImage image = LwgImage.getInstance(i);
if (image.getScaledWidth() > right - left) {
image.scaleToFit(right - left, Float.MAX_VALUE);
}
flushCurrentLine();
if (line == null) {
line = new PdfLine(left, right, alignment, leading);
}
PdfLine imageLine = line;
// left and right in chunk is relative to the start of the line
right = right - left;
left = 0f;
if ((image.getAlignment() & LwgImage.RIGHT) == LwgImage.RIGHT) {
left = right - image.getScaledWidth();
} else if ((image.getAlignment() & LwgImage.MIDDLE) == LwgImage.MIDDLE) {
left = left + ((right - left - image.getScaledWidth()) / 2f);
}
Chunk imageChunk = new Chunk(image, left, 0);
imageLine.add(new PdfChunk(imageChunk, null));
addLine(imageLine);
return imageLine.height();