gnu.jpdf
Class PDFImage

java.lang.Object
  extended by gnu.jpdf.PDFObject
      extended by gnu.jpdf.PDFStream
          extended by gnu.jpdf.PDFImage
All Implemented Interfaces:
java.awt.image.ImageObserver, java.io.Serializable

public class PDFImage
extends PDFStream
implements java.awt.image.ImageObserver, java.io.Serializable

This implements the Image XObject. Calling one of the drawImage methods of PDFGraphics will put all the necessary code into the pdf file, and the image will be encoded in ascii base 85, then deflated in zip format.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gnu.jpdf.PDFObject
objser, pdfDocument
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PDFImage()
          Creates a new PDFImage instance.
PDFImage(java.awt.Image img)
          Creates a new PDFImage instance.
PDFImage(java.awt.Image img, int x, int y, int w, int h, java.awt.image.ImageObserver obs)
          Creates a new PDFImage instance.
 
Method Summary
 int getHeight()
          Get the value of height.
 java.lang.String getName()
          Get the name
 int getWidth()
          Get the value of width.
static java.lang.String handlePixel(int x, int y, int p)
          Converts a pixel to a hex string
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int w, int h)
          Describe imageUpdate method here.
 void setHeight(int v)
          Set the value of height.
 void setImage(java.awt.Image img, int x, int y, int w, int h, java.awt.image.ImageObserver obs)
          Set the image
 void setName(java.lang.String n)
          Set the name
 void setWidth(int v)
          Set the value of width.
 void write(java.io.OutputStream os)
          Compression needs to be improved here
 void writeStream(java.io.OutputStream os)
          Writes the image to the stream
 
Methods inherited from class gnu.jpdf.PDFStream
getDeflate, getOutputStream, getStream, getWriter, setDeflate
 
Methods inherited from class gnu.jpdf.PDFObject
getPDFDocument, getSerialID, getType, toArray, toString, writeEnd, writeStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDFImage

public PDFImage()
Creates a new PDFImage instance.


PDFImage

public PDFImage(java.awt.Image img)
Creates a new PDFImage instance.

Parameters:
img - an Image value

PDFImage

public PDFImage(java.awt.Image img,
                int x,
                int y,
                int w,
                int h,
                java.awt.image.ImageObserver obs)
Creates a new PDFImage instance.

Parameters:
img - an Image value
x - an int value
y - an int value
w - an int value
h - an int value
obs - an ImageObserver value
Method Detail

getWidth

public int getWidth()
Get the value of width.

Returns:
value of width.

setWidth

public void setWidth(int v)
Set the value of width.

Parameters:
v - Value to assign to width.

getHeight

public int getHeight()
Get the value of height.

Returns:
value of height.

setHeight

public void setHeight(int v)
Set the value of height.

Parameters:
v - Value to assign to height.

setName

public void setName(java.lang.String n)
Set the name

Parameters:
n - a String value

getName

public java.lang.String getName()
Get the name

Returns:
a String value

setImage

public void setImage(java.awt.Image img,
                     int x,
                     int y,
                     int w,
                     int h,
                     java.awt.image.ImageObserver obs)
Set the image

Parameters:
img - an Image value
x - an int value
y - an int value
w - an int value
h - an int value
obs - an ImageObserver value

writeStream

public void writeStream(java.io.OutputStream os)
                 throws java.io.IOException
Writes the image to the stream

Overrides:
writeStream in class PDFStream
Parameters:
os - an OutputStream value
Throws:
java.io.IOException - if an error occurs

write

public void write(java.io.OutputStream os)
           throws java.io.IOException

Compression needs to be improved here

Overrides:
write in class PDFStream
Parameters:
os - OutputStream to send the object to
Throws:
java.io.IOException - on error

handlePixel

public static java.lang.String handlePixel(int x,
                                           int y,
                                           int p)

Converts a pixel to a hex string

Parameters:
x - an int value
y - an int value
p - an int value
Returns:
a String value

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int w,
                           int h)
Describe imageUpdate method here.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Parameters:
img - an Image value
infoflags - an int value
x - an int value
y - an int value
w - an int value
h - an int value
Returns:
a boolean value