public class PDFImage extends PDFStream
This implements the Image XObject. This will usually not be used directly; calling one of the drawBitmap
methods of PDFCanvas
will use this to put all the necessary code into the pdf file - the image will be
encoded in ascii base 85 and deflated in zip format.
Constructor and Description |
---|
PDFImage()
Creates a new
PDFImage instance. |
PDFImage(Bitmap bitmap)
Create a new
PDFImage instance based on the supplied Bitmap. |
PDFImage(Bitmap bitmap,
int x,
int y,
int width,
int height)
Create a new
PDFImage instance, based on the subset of the supplied Bitmap at the specified location
and with specified size. |
Modifier and Type | Method and Description |
---|---|
int |
getHeight()
Get the value of height.
|
static String |
getRGBString(int p)
Converts a pixel color to a hex string
|
int |
getWidth()
Get the value of width.
|
void |
setHeight(int v)
Set the value of height.
|
void |
setImage(Bitmap bitmap,
int x,
int y,
int w,
int h)
Set the Bitmap to be embedded, which is the specified subset of the supplied Bitmap.
|
void |
setWidth(int v)
Set the value of width.
|
void |
write(OutputStream os)
Compression needs to be improved here
|
void |
writeStream(OutputStream os)
Writes the image to the stream
|
getDeflate, getOutputStream, getStream, getStreamDataString, getWriter, setDeflate
getGeneration, getName, getPDFDocument, getSerialID, getType, setName, toArray, toString, writeEnd, writeStart
public PDFImage()
PDFImage
instance.public PDFImage(Bitmap bitmap)
PDFImage
instance based on the supplied Bitmap. This will be positioned at location (0,
0) within the PDFPage it's embedded in.bitmap
- the Bitmap
object to embed in the PDF documentpublic PDFImage(Bitmap bitmap, int x, int y, int width, int height)
PDFImage
instance, based on the subset of the supplied Bitmap at the specified location
and with specified size.bitmap
- the Bitmap
to embedx
- subset bitmap positiony
- subset bitmap positionw
- subset bitmap widthh
- subset bitmap heightpublic int getWidth()
public void setWidth(int v)
v
- Value to assign to width.public int getHeight()
public void setHeight(int v)
v
- Value to assign to height.public void setImage(Bitmap bitmap, int x, int y, int w, int h)
bitmap
- the Bitmap
to embedx
- subset bitmap positiony
- subset bitmap positionw
- subset bitmap widthh
- subset bitmap heightpublic void writeStream(OutputStream os) throws IOException
writeStream
in class PDFStream
os
- an OutputStream
valueIOException
- if an error occurspublic void write(OutputStream os) throws IOException
Compression needs to be improved here
write
in class PDFStream
os
- OutputStream to send the object toIOException
- on errorpublic static String getRGBString(int p)
Converts a pixel color to a hex string
p
- Integer representation of pixel's colorString
value giving RGB hex strings concatenated