Class PDFTiledImage

  • All Implemented Interfaces:
    java.awt.image.ImageConsumer

    public class PDFTiledImage
    extends java.lang.Object
    implements java.awt.image.ImageConsumer
    This class handles drawing images as tiles, for when allocating a BufferedImage for the entire pdf image would be too expensive. It implements ImageConsumer, and assumes that it will be passes an ImageProducer that knows how to generate itself top-down/left-right.

    It keeps a BufferedImage only as large as a single tile. When drawImage() is called, the imageProducer is told to generate the image data. As soon as a single tile is filled, it is drawn and the Buffer is reused for the next tile. We could cut out the imageProducer middle-man and just go directly from the codec...

    • Field Summary

      • Fields inherited from interface java.awt.image.ImageConsumer

        COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFTiledImage()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void drawImage​(java.awt.image.ImageProducer ip, java.awt.Graphics2D destination)
      The main entry point.
      static void drawTiledImage​(java.awt.image.ImageProducer ip, java.awt.Graphics2D destination)  
      int getHeight()
      Returns the height of the entire image.
      java.awt.image.WritableRaster getTileBuffer()  
      int getTileHeight()
      Returns the height of the tile (it's a strip)
      int getWidth()
      Returns the width of the entire image.
      void imageComplete​(int status)
      ImageConsumer method.
      void setColorModel​(java.awt.image.ColorModel model)  
      void setDimensions​(int width, int height)
      ImageConsumer method.
      void setHints​(int hintflags)  
      void setPixels​(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)  
      void setPixels​(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)  
      void setProperties​(java.util.Hashtable props)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PDFTiledImage

        public PDFTiledImage()
    • Method Detail

      • getTileHeight

        public int getTileHeight()
        Returns the height of the tile (it's a strip)
      • getWidth

        public int getWidth()
        Returns the width of the entire image.
      • getHeight

        public int getHeight()
        Returns the height of the entire image.
      • imageComplete

        public void imageComplete​(int status)
        ImageConsumer method. Releases the tile.
        Specified by:
        imageComplete in interface java.awt.image.ImageConsumer
      • setHints

        public void setHints​(int hintflags)
        Specified by:
        setHints in interface java.awt.image.ImageConsumer
      • setColorModel

        public void setColorModel​(java.awt.image.ColorModel model)
        Specified by:
        setColorModel in interface java.awt.image.ImageConsumer
      • setDimensions

        public void setDimensions​(int width,
                                  int height)
        ImageConsumer method. Assumption is that this will be called before any calls to setPixels()
        Specified by:
        setDimensions in interface java.awt.image.ImageConsumer
      • getTileBuffer

        public java.awt.image.WritableRaster getTileBuffer()
      • setPixels

        public void setPixels​(int x,
                              int y,
                              int w,
                              int h,
                              java.awt.image.ColorModel model,
                              byte[] pixels,
                              int off,
                              int scansize)
        Specified by:
        setPixels in interface java.awt.image.ImageConsumer
      • setPixels

        public void setPixels​(int x,
                              int y,
                              int w,
                              int h,
                              java.awt.image.ColorModel model,
                              int[] pixels,
                              int off,
                              int scansize)
        Specified by:
        setPixels in interface java.awt.image.ImageConsumer
      • setProperties

        public void setProperties​(java.util.Hashtable props)
        Specified by:
        setProperties in interface java.awt.image.ImageConsumer
      • drawImage

        public void drawImage​(java.awt.image.ImageProducer ip,
                              java.awt.Graphics2D destination)
        The main entry point. Images are drawn at 0,0 so destination should have the image transform applied to it.
      • drawTiledImage

        public static void drawTiledImage​(java.awt.image.ImageProducer ip,
                                          java.awt.Graphics2D destination)