Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pdfbox.pdmodel.graphics.predictor
Class PredictorAlgorithm

    java.lang.Object
      org.pdfbox.pdmodel.graphics.predictor.PredictorAlgorithm

Direct Known Subclasses:
  Average, None, Paeth, Sub, Up, Uptimum

public abstract class PredictorAlgorithm
extends Object

Implements different PNG predictor algorithms that is used in PDF files.

Version:
  $Revision: 1.3 $
Author:
  xylifyx@yahoo.co.uk
See Also:
  PNG Filters

Constructor Summary
`PredictorAlgorithm()`

Method Summary
`int` | `aboveLeftPixel(byte[] buf, int offset, int dy, int x)` Get the above-left pixel from the buffer.
`int` | `abovePixel(byte[] buf, int offset, int dy, int x)` Get the above pixel from the buffer.
`void` | `checkBufsiz(byte[] src, byte[] dest)` check that buffer sizes matches width,height,bpp.
`void` | `decode(byte[] src, byte[] dest)` decode a byte array full of image data using the filter that this object implements.
`abstract void` | `decodeLine(byte[] src, byte[] dest, int srcDy, int srcOffset, int destDy, int destOffset)` decode line of pixel data in src from src_offset and width*bpp bytes forward, put the decoded bytes into dest.
`void` | `encode(byte[] src, byte[] dest)` encode a byte array full of image data using the filter that this object implements.
`abstract void` | `encodeLine(byte[] src, byte[] dest, int srcDy, int srcOffset, int destDy, int destOffset)` encode line of pixel data in src from srcOffset and width*bpp bytes forward, put the decoded bytes into dest.
`int` | `getBpp()`
`static PredictorAlgorithm` | `getFilter(int predictor)`
`int` | `getHeight()`
`int` | `getWidth()`
`int` | `leftPixel(byte[] buf, int offset, int dy, int x)` Get the left pixel from the buffer.
`static void` | `main(String[] args)` Simple command line program to test the algorithm.
`void` | `setBpp(int newBpp)`
`void` | `setHeight(int newHeight)`
`void` | `setWidth(int newWidth)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PredictorAlgorithm

    public PredictorAlgorithm()

Method Detail

### checkBufsiz

    public void checkBufsiz(byte[] src,
                            byte[] dest)

  check that buffer sizes matches width,height,bpp. This implementation is used by most of the filters, but not Uptimum.

  Parameters:
    `src` - The source buffer.
    `dest` - The destination buffer.

### encodeLine

    public abstract void encodeLine(byte[] src,
                                    byte[] dest,
                                    int srcDy,
                                    int srcOffset,
                                    int destDy,
                                    int destOffset)

  encode line of pixel data in src from srcOffset and width*bpp bytes forward, put the decoded bytes into dest.

  Parameters:
    `src` - raw image data
    `dest` - encoded data
    `srcDy` - byte offset between lines
    `srcOffset` - beginning of line data
    `destDy` - byte offset between lines
    `destOffset` - beginning of line data

### decodeLine

    public abstract void decodeLine(byte[] src,
                                    byte[] dest,
                                    int srcDy,
                                    int srcOffset,
                                    int destDy,
                                    int destOffset)

  decode line of pixel data in src from src_offset and width*bpp bytes forward, put the decoded bytes into dest.

  Parameters:
    `src` - encoded image data
    `dest` - raw data
    `srcDy` - byte offset between lines
    `srcOffset` - beginning of line data
    `destDy` - byte offset between lines
    `destOffset` - beginning of line data

### main

    public static void main(String[] args)

  Simple command line program to test the algorithm.

  Parameters:
    `args` - The command line arguments.

### leftPixel

    public int leftPixel(byte[] buf,
                         int offset,
                         int dy,
                         int x)

  Get the left pixel from the buffer.

  Parameters:
    `buf` - The buffer.
    `offset` - The offset into the buffer.
    `dy` - The dy value.
    `x` - The x value.
  Returns:
    The left pixel.

### abovePixel

    public int abovePixel(byte[] buf,
                          int offset,
                          int dy,
                          int x)

  Get the above pixel from the buffer.

  Parameters:
    `buf` - The buffer.
    `offset` - The offset into the buffer.
    `dy` - The dy value.
    `x` - The x value.
  Returns:
    The above pixel.

### aboveLeftPixel

    public int aboveLeftPixel(byte[] buf,
                              int offset,
                              int dy,
                              int x)

  Get the above-left pixel from the buffer.

  Parameters:
    `buf` - The buffer.
    `offset` - The offset into the buffer.
    `dy` - The dy value.
    `x` - The x value.
  Returns:
    The above-left pixel.

### getBpp

    public int getBpp()

  Returns:
    Returns the bpp.

### setBpp

    public void setBpp(int newBpp)

  Parameters:
    `newBpp` - The bpp to set.

### getHeight

    public int getHeight()

  Returns:
    Returns the height.

### setHeight

    public void setHeight(int newHeight)

  Parameters:
    `newHeight` - The height to set.

### getWidth

    public int getWidth()

  Returns:
    Returns the width.

### setWidth

    public void setWidth(int newWidth)

  Parameters:
    `newWidth` - The width to set.

### encode

    public void encode(byte[] src,
                       byte[] dest)

  encode a byte array full of image data using the filter that this object implements.

  Parameters:
    `src` - buffer
    `dest` - buffer

### decode

    public void decode(byte[] src,
                       byte[] dest)

  decode a byte array full of image data using the filter that this object implements.

  Parameters:
    `src` - buffer
    `dest` - buffer

### getFilter

    public static PredictorAlgorithm getFilter(int predictor)

  Parameters:
    `predictor` -
    - 1 No prediction (the default value)
    - 2 TIFF Predictor 2
    - 10 PNG prediction (on encoding, PNG None on all rows)
    - 11 PNG prediction (on encoding, PNG Sub on all rows)
    - 12 PNG prediction (on encoding, PNG Up on all rows)
    - 13 PNG prediction (on encoding, PNG Average on all rows)
    - 14 PNG prediction (on encoding, PNG Paeth on all rows)
    - 15 PNG prediction (on encoding, PNG optimum)
  Returns:
    The predictor class based on the predictor code.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD