Package com.lowagie.text.rtf.graphic
Class RtfImage
java.lang.Object
com.lowagie.text.rtf.RtfElement
com.lowagie.text.rtf.graphic.RtfImage
- All Implemented Interfaces:
RtfBasicElement
,com.lowagie.text.RtfElementInterface
The RtfImage contains one image. Supported image types are jpeg, png, wmf, bmp.
- Version:
- $Id: RtfImage.java 4065 2009-09-16 23:09:11Z psoares33 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The alignment of this picturestatic final byte[]
lookup table used for converting bytes to hex chars.private final float
The height of this pictureprivate final byte[][]
Binary image data.private final int
The type of image this is.private static final byte[]
Constant for a pictureprivate static final byte[]
"\bin" constantprivate static final byte[]
Constant for the shape/picture groupprivate static final byte[]
Constant for the picture heightprivate static final byte[]
Constant for a jpeg imageprivate static final byte[]
Constant for a png imageprivate static final byte[]
Constant for horizontal picture scalingprivate static final byte[]
Constant for vertical picture scalingprivate static final byte[]
Constant for the picture height scaleprivate static final byte[]
Constant for the picture width scaleprivate static final byte[]
Constant for the picture widthprivate static final byte[]
Constant for a wmf imageprivate static final int
Constant for converting pixels to twipsprivate final float
The intended display height of this pictureprivate final float
The intended display width of this pictureprivate boolean
Whether this RtfImage is a top level element and should be an extra paragraph.private final float
The width of this pictureFields inherited from class com.lowagie.text.rtf.RtfElement
document, inHeader, inTable
Fields inherited from interface com.lowagie.text.rtf.RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR
-
Constructor Summary
ConstructorsConstructorDescriptionRtfImage
(RtfDocument doc, com.lowagie.text.Image image) Constructs a RtfImage for an Image. -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[][]
getImageData
(com.lowagie.text.Image image) Extracts the image data from the Image.private int
Returns the image raw data size in bytes.void
setAlignment
(int alignment) Sets the alignment of this RtfImage.void
setTopLevelElement
(boolean topLevelElement) Set whether this RtfImage should behave like a top level element and enclose itself in a paragraph.void
writeContent
(OutputStream result) Writes the RtfImage contentprivate void
Writes the image data to the given buffer as hex encoded text.Methods inherited from class com.lowagie.text.rtf.RtfElement
intToByteArray, isInTable, setInHeader, setInTable, setRtfDocument
-
Field Details
-
PICTURE_GROUP
private static final byte[] PICTURE_GROUPConstant for the shape/picture group -
PICTURE
private static final byte[] PICTUREConstant for a picture -
PICTURE_JPEG
private static final byte[] PICTURE_JPEGConstant for a jpeg image -
PICTURE_PNG
private static final byte[] PICTURE_PNGConstant for a png image -
PICTURE_WMF
private static final byte[] PICTURE_WMFConstant for a wmf image -
PICTURE_WIDTH
private static final byte[] PICTURE_WIDTHConstant for the picture width -
PICTURE_HEIGHT
private static final byte[] PICTURE_HEIGHTConstant for the picture height -
PICTURE_SCALED_WIDTH
private static final byte[] PICTURE_SCALED_WIDTHConstant for the picture width scale -
PICTURE_SCALED_HEIGHT
private static final byte[] PICTURE_SCALED_HEIGHTConstant for the picture height scale -
PICTURE_SCALE_X
private static final byte[] PICTURE_SCALE_XConstant for horizontal picture scaling -
PICTURE_SCALE_Y
private static final byte[] PICTURE_SCALE_YConstant for vertical picture scaling -
PICTURE_BINARY_DATA
private static final byte[] PICTURE_BINARY_DATA"\bin" constant -
PIXEL_TWIPS_FACTOR
private static final int PIXEL_TWIPS_FACTORConstant for converting pixels to twips- See Also:
-
imageType
private final int imageTypeThe type of image this is. -
imageData
private final byte[][] imageDataBinary image data. -
alignment
private int alignmentThe alignment of this picture -
width
private final float widthThe width of this picture -
height
private final float heightThe height of this picture -
plainWidth
private final float plainWidthThe intended display width of this picture -
plainHeight
private final float plainHeightThe intended display height of this picture -
topLevelElement
private boolean topLevelElementWhether this RtfImage is a top level element and should be an extra paragraph. -
byte2charLUT
public static final byte[] byte2charLUTlookup table used for converting bytes to hex chars. TODO Should probably be refactored into a helper class
-
-
Constructor Details
-
RtfImage
public RtfImage(RtfDocument doc, com.lowagie.text.Image image) throws com.lowagie.text.DocumentException Constructs a RtfImage for an Image.- Parameters:
doc
- The RtfDocument this RtfImage belongs toimage
- The Image that this RtfImage wraps- Throws:
com.lowagie.text.DocumentException
- If an error occurred accessing the image content
-
-
Method Details
-
getImageData
private byte[][] getImageData(com.lowagie.text.Image image) throws com.lowagie.text.DocumentException 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:
com.lowagie.text.DocumentException
- If an error occurs accessing the image content
-
writeImageDataHexEncoded
Writes the image data to the given buffer as hex encoded text.- Parameters:
bab
-- Throws:
IOException
-
imageDataSize
private int imageDataSize()Returns the image raw data size in bytes.- Returns:
- the size in bytes
-
writeContent
Writes the RtfImage content- Specified by:
writeContent
in interfaceRtfBasicElement
- Specified by:
writeContent
in classRtfElement
- Parameters:
result
- TheOutputStream
to write the content to- Throws:
IOException
-
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.
-