Package pdf

Class 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 interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      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.
    • 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