Package com.microblink.blinkid.image
Class Image
java.lang.Object
com.microblink.blinkid.image.Image
- All Implemented Interfaces:
android.os.Parcelable
Represents a image that is being processed.
-
Nested Class Summary
-
Field Summary
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates and returns a copy of this image object.android.graphics.Bitmap
Converts this image into Android Bitmap.int
void
dispose()
Disposes native object containing image pixels.protected void
finalize()
Returns the native buffer that contains image pixels.int
Returns the height of the image (corrected for the current orientation).Returns the format of the image.Deprecated.Do not rely on this information anymore.Returns the orientation of the image.int
Returns the pixel stride for image buffer.int
Returns the raw height of the image (uncorrected for the orientation)int
Returns the raw width of the image (uncorrected for the orientation)int
Returns the row stride for image buffer.int
getWidth()
Returns the width of the image (corrected for the current orientation).boolean
Returns true if image's internal buffers are disposed and cannot be used anymore.void
setImageOrientation
(Orientation orientation) Use this method to change Image's orientation.void
writeToParcel
(android.os.Parcel dest, int flags)
-
Field Details
-
CREATOR
-
-
Constructor Details
-
Image
protected Image(@NonNull android.os.Parcel in)
-
-
Method Details
-
dispose
public void dispose()Disposes native object containing image pixels. After this method is called, Image object cannot be used anymore. -
finalize
-
clone
Creates and returns a copy of this image object. This method makes a copy of image pixels. Use it if you want to use this image for later processing. -
getWidth
public int getWidth()Returns the width of the image (corrected for the current orientation).- Returns:
- the width of the image (corrected for the current orientation).
-
getRawWidth
public int getRawWidth()Returns the raw width of the image (uncorrected for the orientation) -
getHeight
public int getHeight()Returns the height of the image (corrected for the current orientation).- Returns:
- the height of the image (corrected for the current orientation).
-
getRawHeight
public int getRawHeight()Returns the raw height of the image (uncorrected for the orientation) -
getImageFormat
Returns the format of the image.- Returns:
- the format of the image.
-
getImageName
Deprecated.Do not rely on this information anymore. New API images will be nameless.Returns the name of the image.- Returns:
- the name of the image.
-
getBuffer
Returns the native buffer that contains image pixels.- Returns:
- the native buffer that contains image pixels.
-
getPixelStride
public int getPixelStride()Returns the pixel stride for image buffer. Pixel stride is byte difference between two consecutive pixels image row. It is guaranteed that pixel stride is at least 1.- Returns:
- the pixel stride for image buffer.
-
getRowStride
public int getRowStride()Returns the row stride for image buffer. Row stride is byte difference between two consecutive rows in image.- Returns:
- the row stride for image plane
-
getImageOrientation
Returns the orientation of the image. Orientation is defined as orientation of the device when the image was taken. To explain the orientation further, let's assume that image contains a line of text. If orientation is Orientation.ORIENTATION_LANDSCAPE_RIGHT, the line of text would be horizontal from left to right (normal reading orientation). If orientation is Orientation.ORIENTATION_PORTRAIT, the line of text would be vertical from bottom to top. In order to read the text, you would need to rotate image by 90 degrees clockwise. If orientation is Orientation.ORIENTATION_PORTRAIT_UPSIDE, the line of text would be vertical from top to bottom. In order to read the text, you would need to rotate image by 90 degrees counterclockwise. If orientation is Orientation.ORIENTATION_LANDSCAPE_LEFT, the line of text would be horizontal from right to left (upside down). In order to read the text, you would need to rotate image by 180 degrees.- Returns:
- the orientation of the image
-
setImageOrientation
Use this method to change Image's orientation. This can be useful for different interpretations of same image in different recognition contexts.- Parameters:
orientation
-
-
isDisposed
public boolean isDisposed()Returns true if image's internal buffers are disposed and cannot be used anymore.- Returns:
- true if image's internal buffers are disposed and cannot be used anymore.
-
convertToBitmap
@Nullable public android.graphics.Bitmap convertToBitmap()Converts this image into Android Bitmap. This is a very slow process that involves copying and converting a lot of data. Returned bitmap has its own pixel buffer, so it may remain valid even after this image's buffers become invalid (i.e. after image gets disposed).- Returns:
- Image converted to Android Bitmap or null if conversion failed.
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) - Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-
toInputImage
-