com.lowagie.text.rtf.graphic

Class RtfImage

public class RtfImage extends RtfElement

The RtfImage contains one image. Supported image types are jpeg, png, wmf, bmp.

Version: $Id: RtfImage.java 2825 2007-06-04 09:15:21Z blowagie $

Author: Mark Hall (mhall@edu.uni-klu.ac.at) Paulo Soares Thomas Bickel (tmb99@inode.at)

Field Summary
intalignment
The alignment of this picture
static byte[]byte2charLUT
lookup table used for converting bytes to hex chars.
floatheight
The height of this picutre
byte[][]imageData
Binary image data.
intimageType
The type of image this is.
floatplainHeight
The intended display height of this picture
floatplainWidth
The intended display width of this picture
static byte[]PICTURE
Constant for a picture
static byte[]PICTURE_BINARY_DATA
"\bin" constant
static byte[]PICTURE_BMP
Constant for a bmp image
static byte[]PICTURE_GROUP
Constant for the shape/picture group
static byte[]PICTURE_HEIGHT
Constant for the picture height
static byte[]PICTURE_JPEG
Constant for a jpeg image
static byte[]PICTURE_PNG
Constant for a png image
static byte[]PICTURE_SCALED_HEIGHT
Constant for the picture height scale
static byte[]PICTURE_SCALED_WIDTH
Constant for the picture width scale
static byte[]PICTURE_SCALE_X
Constant for horizontal picture scaling
static byte[]PICTURE_SCALE_Y
Constant for vertical picture scaling
static byte[]PICTURE_WIDTH
Constant for the picture width
static byte[]PICTURE_WMF
Constant for a wmf image
static intPIXEL_TWIPS_FACTOR
Constant for converting pixels to twips
booleantopLevelElement
Whether this RtfImage is a top level element and should be an extra paragraph.
floatwidth
The width of this picture
Constructor Summary
RtfImage(RtfDocument doc, Image image)
Constructs a RtfImage for an Image.
Method Summary
byte[][]getImageData(Image image)
Extracts the image data from the Image.
intimageDataSize()
Returns the image raw data size in bytes.
voidsetAlignment(int alignment)
Sets the alignment of this RtfImage.
voidsetTopLevelElement(boolean topLevelElement)
Set whether this RtfImage should behave like a top level element and enclose itself in a paragraph.
byte[]write()
Writes the RtfImage content
voidwriteContent(OutputStream result)
Writes the RtfImage content
voidwriteImageDataHexEncoded(OutputStream bab)
Writes the image data to the given buffer as hex encoded text.

Field Detail

alignment

private int alignment
The alignment of this picture

byte2charLUT

public static final byte[] byte2charLUT
lookup table used for converting bytes to hex chars. TODO Should probably be refactored into a helper class

height

private float height
The height of this picutre

imageData

private final byte[][] imageData
Binary image data.

imageType

private final int imageType
The type of image this is.

plainHeight

private float plainHeight
The intended display height of this picture

plainWidth

private float plainWidth
The intended display width of this picture

PICTURE

private static final byte[] PICTURE
Constant for a picture

PICTURE_BINARY_DATA

private static final byte[] PICTURE_BINARY_DATA
"\bin" constant

PICTURE_BMP

private static final byte[] PICTURE_BMP
Constant for a bmp image

PICTURE_GROUP

private static final byte[] PICTURE_GROUP
Constant for the shape/picture group

PICTURE_HEIGHT

private static final byte[] PICTURE_HEIGHT
Constant for the picture height

PICTURE_JPEG

private static final byte[] PICTURE_JPEG
Constant for a jpeg image

PICTURE_PNG

private static final byte[] PICTURE_PNG
Constant for a png image

PICTURE_SCALED_HEIGHT

private static final byte[] PICTURE_SCALED_HEIGHT
Constant for the picture height scale

PICTURE_SCALED_WIDTH

private static final byte[] PICTURE_SCALED_WIDTH
Constant for the picture width scale

PICTURE_SCALE_X

private static final byte[] PICTURE_SCALE_X
Constant for horizontal picture scaling

PICTURE_SCALE_Y

private static final byte[] PICTURE_SCALE_Y
Constant for vertical picture scaling

PICTURE_WIDTH

private static final byte[] PICTURE_WIDTH
Constant for the picture width

PICTURE_WMF

private static final byte[] PICTURE_WMF
Constant for a wmf image

PIXEL_TWIPS_FACTOR

private static final int PIXEL_TWIPS_FACTOR
Constant for converting pixels to twips

topLevelElement

private boolean topLevelElement
Whether this RtfImage is a top level element and should be an extra paragraph.

width

private float width
The width of this picture

Constructor Detail

RtfImage

public RtfImage(RtfDocument doc, Image image)
Constructs a RtfImage for an Image.

Parameters: doc The RtfDocument this RtfImage belongs to image The Image that this RtfImage wraps

Throws: DocumentException If an error occured accessing the image content

Method Detail

getImageData

private byte[][] getImageData(Image image)
Extracts the image data from the Image.

Parameters: image The image for which to extract the content

Returns: The raw image data, not formated

Throws: DocumentException If an error occurs accessing the image content

imageDataSize

private int imageDataSize()
Returns the image raw data size in bytes.

Returns: the size in bytes

setAlignment

public void setAlignment(int alignment)
Sets the alignment of this RtfImage. Uses the alignments from com.lowagie.text.Element.

Parameters: alignment The alignment to use.

setTopLevelElement

public void setTopLevelElement(boolean topLevelElement)
Set whether this RtfImage should behave like a top level element and enclose itself in a paragraph.

Parameters: topLevelElement Whether to behave like a top level element.

write

public byte[] write()

Deprecated: replaced by writeContent

Writes the RtfImage content

Returns: the RtfImage content

writeContent

public void writeContent(OutputStream result)
Writes the RtfImage content

writeImageDataHexEncoded

private void writeImageDataHexEncoded(OutputStream bab)
Writes the image data to the given buffer as hex encoded text.

Parameters: bab

Throws: IOException