Class PredictorAlgorithm
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.graphics.predictor.PredictorAlgorithm
-
-
Constructor Summary
Constructors Constructor Description PredictorAlgorithm()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intaboveLeftPixel(byte[] buf, int offset, int dy, int x)Get the above-left pixel from the buffer.intabovePixel(byte[] buf, int offset, int dy, int x)Get the above pixel from the buffer.voidcheckBufsiz(byte[] src, byte[] dest)check that buffer sizes matches width,height,bpp.voiddecode(byte[] src, byte[] dest)decode a byte array full of image data using the filter that this object implements.abstract voiddecodeLine(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.voidencode(byte[] src, byte[] dest)encode a byte array full of image data using the filter that this object implements.abstract voidencodeLine(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.intgetBpp()static PredictorAlgorithmgetFilter(int predictor)intgetHeight()intgetWidth()intleftPixel(byte[] buf, int offset, int dy, int x)Get the left pixel from the buffer.static voidmain(String[] args)Simple command line program to test the algorithm.voidsetBpp(int newBpp)voidsetHeight(int newHeight)voidsetWidth(int newWidth)
-
-
-
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 datadest- encoded datasrcDy- byte offset between linessrcOffset- beginning of line datadestDy- byte offset between linesdestOffset- 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 datadest- raw datasrcDy- byte offset between linessrcOffset- beginning of line datadestDy- byte offset between linesdestOffset- 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- bufferdest- 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- bufferdest- 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.
-
-