public class Pix
Java representation of a native Leptonica PIX object.
public static int INDEX_W
Index of the image width within the dimensions array.
public static int INDEX_H
Index of the image height within the dimensions array.
public static int INDEX_D
Index of the image bit-depth within the dimensions array.
public Pix(long nativePix)
Creates a new Pix wrapper for the specified native PIX object.
nativePix - A pointer to the native PIX object.public Pix(int width,
int height,
int depth)
public long getNativePix()
Returns a pointer to the native Pix object. This is used by native code and is only valid within the same process in which the Pix was created.
public kotlin.Array[] getData()
Return the raw bytes of the native PIX object. You can reconstruct the Pix from this data using createFromPix().
public kotlin.Array[] getDimensions()
Returns an array of this image's dimensions. See Pix.INDEX_* for indices.
null on failurepublic boolean getDimensions(@Size
kotlin.Array[] dimensions)
Fills an array with this image's dimensions. The array must be at least 3 elements long.
dimensions - An integer array with at least three elements.true on successpublic Pix clone()
Returns a clone of this Pix. This does NOT create a separate copy, just a new pointer that can be recycled without affecting other clones.
public Pix copy()
Returns a deep copy of this Pix that can be modified without affecting the original Pix.
public boolean invert()
Inverts this Pix in-place.
true on successpublic void recycle()
Releases resources and frees any memory associated with this Pix. You may not modify or access the pix after calling this method.
public static Pix createFromPix(kotlin.Array[] pixData, int width, int height, int depth)
Creates a new Pix from raw Pix data obtained from getData().
pixData - Raw pix data obtained from getData().width - The width of the original Pix.height - The height of the original Pix.depth - The bit-depth of the original Pix.null on errorpublic android.graphics.Rect getRect()
Returns a Rect with the width and height of this Pix.
public int getWidth()
Returns the width of this Pix.
public int getHeight()
Returns the height of this Pix.
public int getDepth()
Returns the depth of this Pix.
public int getRefCount()
public int getPixel(int x,
int y)
Returns the android.graphics.Color at the specified location.
x - The x coordinate (0...width-1) of the pixel to return.y - The y coordinate (0...height-1) of the pixel to return.android.graphics.Color at the specified coordinate.IllegalArgumentException - If x, y exceeds the image bounds.public void setPixel(int x,
int y,
@ColorInt
int color)
Sets the android.graphics.Color at the specified location.
x - The x coordinate (0...width-1) of the pixel to set.y - The y coordinate (0...height-1) of the pixel to set.color - The argb android.graphics.Color to set at the specified coordinate.IllegalArgumentException - If x, y exceeds the image bounds.