public class Pixa
Java representation of a native PIXA object. This object contains multiple PIX objects and their associated bounding BOX objects.
public Pixa(long nativePixa,
int width,
int height)
Creates a wrapper for the specified native Pixa pointer.
nativePixa - Native pointer to a PIXA object.width - The width of the PIXA.height - The height of the PIXA.public static Pixa createPixa(int size)
Creates a new Pixa with the specified minimum capacity. The Pixa will expand automatically as new Pix are added.
size - The minimum capacity of this Pixa.null on errorpublic static Pixa createPixa(int size, int width, int height)
Creates a new Pixa with the specified minimum capacity. The Pixa will expand automatically as new Pix are added.
If non-zero, the specified width and height will be used to specify the bounds of output images. *
size - The minimum capacity of this Pixa.width - (Optional) The width of this Pixa, use 0 for default.height - (Optional) The height of this Pixa, use 0 for default.null on errorpublic long getNativePixa()
Returns a pointer to the native PIXA object. This is used by native code.
public Pixa copy()
Creates a shallow copy of this Pixa. Contained Pix are cloned, and the resulting Pixa may be recycled separately from the original.
public Pixa sort(int field, int order)
Sorts this Pixa using the specified field and order. See Constants.L_SORT_BY_* and Constants.L_SORT_INCREASING or Constants.L_SORT_DECREASING.
field - The field to sort by. See Constants.L_SORT_BY_*.order - The order in which to sort. Must be either Constants.L_SORT_INCREASING or Constants.L_SORT_DECREASING.public int size()
Returns the number of elements in this Pixa.
public void recycle()
Recycles this Pixa and frees natively allocated memory. You may not access or modify the Pixa after calling this method.
Any Pix obtained from this Pixa or copies of this Pixa will still be accessible until they are explicitly recycled or finalized by the garbage collector.
protected void finalize()
public boolean join(Pixa otherPixa)
Merges the contents of another Pixa into this one.
otherPixa - The Pix to merge.true on successpublic void addPix(Pix pix, int mode)
Adds a Pix to this Pixa.
pix - The Pix to add.mode - The mode in which to add this Pix, typically Constants.L_CLONE.public void addBox(Box box, int mode)
Adds a Box to this Pixa.
box - The Box to add.mode - The mode in which to add this Box, typically Constants.L_CLONE.public void add(Pix pix, Box box, int mode)
Adds a Pix and associated Box to this Pixa.
pix - The Pix to add.box - The Box to add.mode - The mode in which to add this Pix and Box, typically Constants.L_CLONE.public Box getBox(int index)
Returns the Box at the specified index, or null on error.
index - The index of the Box to return.null on errorpublic Pix getPix(int index)
Returns the Pix at the specified index, or null on error.
index - The index of the Pix to return.null on errorpublic int getWidth()
Returns the width of this Pixa, or 0 if one was not set when it was created.
public int getHeight()
Returns the height of this Pixa, or 0 if one was not set when it was created.
public android.graphics.Rect getRect()
Returns a bounding Rect for this Pixa, which may be (0,0,0,0) if width and height were not specified on creation.
public kotlin.Array[] getBoxGeometry(int index)
Returns a geometry array for the Box at the specified index. See Box.INDEX_* for indices.
index - The index of the Box to get the geometry of.public boolean getBoxGeometry(int index,
@Size
kotlin.Array[] dimensions)
Fills an array with the geometry of the Box at the specified index. See Box.INDEX_* for indices.
index - The index of the Box to get the geometry of.dimensions - The array to fill with Box geometry. Must be at least 4 elements.true on successpublic android.graphics.Rect getBoxRect(int index)
Returns a bounding Rect for the Box at the specified index.
index - The index of the Box to get the bounding Rect of.public java.util.ArrayList<android.graphics.Rect> getBoxRects()
Returns an ArrayList of Box bounding Rects.
public void replacePix(int index,
Pix pix,
Box box)
Replaces the Pix and Box at the specified index with the specified Pix and Box, both of which may be recycled after calling this method.
index - The index of the Pix to replace.pix - The Pix to replace the existing Pix.box - The Box to replace the existing Box.public void mergeAndReplacePix(int indexA,
int indexB)
Merges the Pix at the specified indices and removes the Pix at the second index.
indexA - The index of the first Pix.indexB - The index of the second Pix, which will be removed after merging.public boolean writeToFileRandomCmap(java.io.File file)
Writes the components of this Pix to a bitmap-formatted file using a random color map.
file - The file to write to.true on successpublic java.util.Iterator<com.googlecode.leptonica.android.Pix> iterator()