Package 

Class CameraUtils


  • 
    public class CameraUtils
    
                        

    Static utilities for dealing with camera I/O, orientations, etc.

    • 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 context
        facing - 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 written
        file - 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 written
        file - the file to write into
        callback - 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 array
        callback - 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 array
        maxWidth - the max allowed width
        maxHeight - the max allowed height
        callback - 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 array
        maxWidth - the max allowed width
        maxHeight - the max allowed height
        options - the options to be passed to decodeByteArray
        callback - 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 array
        maxWidth - the max allowed width
        maxHeight - 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 array
        maxWidth - the max allowed width
        maxHeight - the max allowed height
        options - the options to be passed to decodeByteArray