-
public class CameraUtilsStatic utilities for dealing with camera I/O, orientations, etc.
-
-
Method Summary
Modifier and Type Method Description static booleanhasCameras(@NonNull() Context context)Determines whether the device has valid camera sensors, so the librarycan be used. static booleanhasCameraFacing(@NonNull() Context context, @NonNull() Facing facing)Determines whether the device has a valid camera sensor with the givenFacing value, so that a session can be started. static FilewriteToFile(@NonNull() Array<byte> data, @NonNull() File file)Simply writes the given data to the given file. static voidwriteToFile(@NonNull() Array<byte> data, @NonNull() File file, @NonNull() FileCallback callback)Writes the given data to the given file in a background thread, returning on theoriginal thread (typically the UI thread) once writing is done. static BitmapdecodeBitmap(@NonNull() Array<byte> source)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. static voiddecodeBitmap(@NonNull() Array<byte> source, @NonNull() BitmapCallback callback)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. static voiddecodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapCallback callback)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. static voiddecodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapFactory.Options options, @NonNull() BitmapCallback callback)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. static BitmapdecodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. static BitmapdecodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapFactory.Options options)Decodes an input byte array and outputs a Bitmap that is ready to be displayed. -
-
Method Detail
-
hasCameras
static boolean hasCameras(@NonNull() Context context)
Determines whether the device has valid camera sensors, so the librarycan be used.
- Parameters:
context- a valid Context
-
hasCameraFacing
static boolean hasCameraFacing(@NonNull() Context context, @NonNull() Facing facing)
Determines whether the device has a valid camera sensor with the givenFacing value, so that a session can be started.
- Parameters:
context- a valid contextfacing- either BACK or FRONT
-
writeToFile
@Nullable()@WorkerThread() static File writeToFile(@NonNull() Array<byte> data, @NonNull() File file)
Simply writes the given data to the given file. It is done synchronously. If you arerunning on the UI thread, please use writeToFile and pass a file callback.If any error is encountered, this returns null.
- Parameters:
data- the data to be writtenfile- the file to write into
-
writeToFile
static void writeToFile(@NonNull() Array<byte> data, @NonNull() File file, @NonNull() FileCallback callback)
Writes the given data to the given file in a background thread, returning on theoriginal thread (typically the UI thread) once writing is done.If some error is encountered, the FileCallback will return null instead of theoriginal file.
- Parameters:
data- the data to be writtenfile- the file to write intocallback- a callback
-
decodeBitmap
@Nullable()@WorkerThread() static Bitmap decodeBitmap(@NonNull() Array<byte> source)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.
- Parameters:
source- a JPEG byte array
-
decodeBitmap
static void decodeBitmap(@NonNull() Array<byte> source, @NonNull() BitmapCallback callback)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.This is executed in a background thread, and returns the result to the original thread.
- Parameters:
source- a JPEG byte arraycallback- a callback to be notified
-
decodeBitmap
static void decodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapCallback callback)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.This is executed in a background thread, and returns the result to the original thread.The image is also downscaled taking care of the maxWidth and maxHeight arguments.
- Parameters:
source- a JPEG byte arraymaxWidth- the max allowed widthmaxHeight- the max allowed heightcallback- a callback to be notified
-
decodeBitmap
static void decodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapFactory.Options options, @NonNull() BitmapCallback callback)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.This is executed in a background thread, and returns the result to the original thread.The image is also downscaled taking care of the maxWidth and maxHeight arguments.
- Parameters:
source- a JPEG byte arraymaxWidth- the max allowed widthmaxHeight- the max allowed heightoptions- the options to be passed to decodeByteArraycallback- a callback to be notified
-
decodeBitmap
@Nullable()@WorkerThread() static Bitmap decodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.The image is also downscaled taking care of the maxWidth and maxHeight arguments.
- Parameters:
source- a JPEG byte arraymaxWidth- the max allowed widthmaxHeight- the max allowed height
-
decodeBitmap
@Nullable()@WorkerThread() static Bitmap decodeBitmap(@NonNull() Array<byte> source, int maxWidth, int maxHeight, @NonNull() BitmapFactory.Options options)
Decodes an input byte array and outputs a Bitmap that is ready to be displayed.The difference with decodeByteArray is that this cares about orientation, reading it from the EXIF header.The image is also downscaled taking care of the maxWidth and maxHeight arguments.
- Parameters:
source- a JPEG byte arraymaxWidth- the max allowed widthmaxHeight- the max allowed heightoptions- the options to be passed to decodeByteArray
-
-
-
-