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,RtfElementInterface
public class RtfImage extends RtfElement
The RtfImage contains one image. Supported image types are jpeg, png, wmf, bmp.- Version:
- $Id: RtfImage.java 3580 2008-08-06 15:52:00Z howard_s $
- Author:
- Mark Hall (Mark.Hall@mail.room3b.eu), Paulo Soares, Thomas Bickel (tmb99@inode.at)
-
-
Field Summary
Fields Modifier and Type Field Description private intalignmentThe alignment of this picturestatic byte[]byte2charLUTlookup table used for converting bytes to hex chars.private floatheightThe height of this pictureprivate byte[][]imageDataBinary image data.private intimageTypeThe type of image this is.private static byte[]PICTUREConstant for a pictureprivate static byte[]PICTURE_BINARY_DATA"\bin" constantprivate static byte[]PICTURE_GROUPConstant for the shape/picture groupprivate static byte[]PICTURE_HEIGHTConstant for the picture heightprivate static byte[]PICTURE_JPEGConstant for a jpeg imageprivate static byte[]PICTURE_PNGConstant for a png imageprivate static byte[]PICTURE_SCALE_XConstant for horizontal picture scalingprivate static byte[]PICTURE_SCALE_YConstant for vertical picture scalingprivate static byte[]PICTURE_SCALED_HEIGHTConstant for the picture height scaleprivate static byte[]PICTURE_SCALED_WIDTHConstant for the picture width scaleprivate static byte[]PICTURE_WIDTHConstant for the picture widthprivate static byte[]PICTURE_WMFConstant for a wmf imageprivate static intPIXEL_TWIPS_FACTORConstant for converting pixels to twipsprivate floatplainHeightThe intended display height of this pictureprivate floatplainWidthThe intended display width of this pictureprivate booleantopLevelElementWhether this RtfImage is a top level element and should be an extra paragraph.private floatwidthThe width of this picture-
Fields 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
Constructors Constructor Description RtfImage(RtfDocument doc, Image image)Constructs a RtfImage for an Image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[][]getImageData(Image image)Extracts the image data from the Image.private 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.voidwriteContent(java.io.OutputStream result)Writes the RtfImage contentprivate voidwriteImageDataHexEncoded(java.io.OutputStream bab)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 Detail
-
PICTURE_GROUP
private static final byte[] PICTURE_GROUP
Constant for the shape/picture group
-
PICTURE
private static final byte[] PICTURE
Constant for a picture
-
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_WMF
private static final byte[] PICTURE_WMF
Constant for a wmf image
-
PICTURE_WIDTH
private static final byte[] PICTURE_WIDTH
Constant for the picture width
-
PICTURE_HEIGHT
private static final byte[] PICTURE_HEIGHT
Constant for the picture height
-
PICTURE_SCALED_WIDTH
private static final byte[] PICTURE_SCALED_WIDTH
Constant for the picture width scale
-
PICTURE_SCALED_HEIGHT
private static final byte[] PICTURE_SCALED_HEIGHT
Constant for the picture height 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_BINARY_DATA
private static final byte[] PICTURE_BINARY_DATA
"\bin" constant
-
PIXEL_TWIPS_FACTOR
private static final int PIXEL_TWIPS_FACTOR
Constant for converting pixels to twips- See Also:
- Constant Field Values
-
imageType
private final int imageType
The type of image this is.
-
imageData
private final byte[][] imageData
Binary image data.
-
alignment
private int alignment
The alignment of this picture
-
width
private float width
The width of this picture
-
height
private float height
The height of this picture
-
plainWidth
private float plainWidth
The intended display width of this picture
-
plainHeight
private float plainHeight
The intended display height of this picture
-
topLevelElement
private boolean topLevelElement
Whether this RtfImage is a top level element and should be an extra paragraph.
-
byte2charLUT
public static final byte[] byte2charLUT
lookup table used for converting bytes to hex chars. TODO Should probably be refactored into a helper class
-
-
Constructor Detail
-
RtfImage
public RtfImage(RtfDocument doc, Image image) throws DocumentException
Constructs a RtfImage for an Image.- Parameters:
doc- The RtfDocument this RtfImage belongs toimage- The Image that this RtfImage wraps- Throws:
DocumentException- If an error occurred accessing the image content
-
-
Method Detail
-
getImageData
private byte[][] getImageData(Image image) throws 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:
DocumentException- If an error occurs accessing the image content
-
writeImageDataHexEncoded
private void writeImageDataHexEncoded(java.io.OutputStream bab) throws java.io.IOExceptionWrites the image data to the given buffer as hex encoded text.- Parameters:
bab-- Throws:
java.io.IOException
-
imageDataSize
private int imageDataSize()
Returns the image raw data size in bytes.- Returns:
- the size in bytes
-
writeContent
public void writeContent(java.io.OutputStream result) throws java.io.IOExceptionWrites the RtfImage content- Specified by:
writeContentin interfaceRtfBasicElement- Specified by:
writeContentin classRtfElement- Parameters:
result- TheOutputStreamto write the content to- Throws:
java.io.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.
-
-