public final class

BitmapUtil

extends Object
java.lang.Object
   ↳ com.facebook.imageutils.BitmapUtil

Class Overview

This class contains utility method for Bitmap

Summary

Constants
int ALPHA_8_BYTES_PER_PIXEL Bytes per pixel definitions
int ARGB_4444_BYTES_PER_PIXEL
int ARGB_8888_BYTES_PER_PIXEL
float MAX_BITMAP_SIZE
int RGBA_F16_BYTES_PER_PIXEL
int RGB_565_BYTES_PER_PIXEL
Public Constructors
BitmapUtil()
Public Methods
static Pair<Integer, Integer> decodeDimensions(Uri uri)
Decodes the bounds of an image from its Uri and returns a pair of the dimensions
static Pair<Integer, Integer> decodeDimensions(byte[] bytes)
Decodes only the bounds of an image and returns its width and height or null if the size can't be determined
static Pair<Integer, Integer> decodeDimensions(InputStream is)
Decodes the bounds of an image and returns its width and height or null if the size can't be determined
static ImageMetaData decodeDimensionsAndColorSpace(InputStream is)
Decodes the bounds of an image and returns its width and height or null if the size can't be determined.
static int getPixelSizeForBitmapConfig(Bitmap.Config bitmapConfig)
Returns the amount of bytes used by a pixel in a specific android.graphics.Bitmap.Config
static int getSizeInByteForBitmap(int width, int height, Bitmap.Config bitmapConfig)
Returns the size in byte of an image with specific size and android.graphics.Bitmap.Config
static int getSizeInBytes(Bitmap bitmap)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ALPHA_8_BYTES_PER_PIXEL

Bytes per pixel definitions

Constant Value: 1 (0x00000001)

public static final int ARGB_4444_BYTES_PER_PIXEL

Constant Value: 2 (0x00000002)

public static final int ARGB_8888_BYTES_PER_PIXEL

Constant Value: 4 (0x00000004)

public static final float MAX_BITMAP_SIZE

Constant Value: 2048.0

public static final int RGBA_F16_BYTES_PER_PIXEL

Constant Value: 8 (0x00000008)

public static final int RGB_565_BYTES_PER_PIXEL

Constant Value: 2 (0x00000002)

Public Constructors

public BitmapUtil ()

Public Methods

public static Pair<Integer, Integer> decodeDimensions (Uri uri)

Decodes the bounds of an image from its Uri and returns a pair of the dimensions

Parameters
uri the Uri of the image
Returns
  • dimensions of the image

public static Pair<Integer, Integer> decodeDimensions (byte[] bytes)

Decodes only the bounds of an image and returns its width and height or null if the size can't be determined

Parameters
bytes the input byte array of the image
Returns
  • dimensions of the image

public static Pair<Integer, Integer> decodeDimensions (InputStream is)

Decodes the bounds of an image and returns its width and height or null if the size can't be determined

Parameters
is the InputStream containing the image data
Returns
  • dimensions of the image

public static ImageMetaData decodeDimensionsAndColorSpace (InputStream is)

Decodes the bounds of an image and returns its width and height or null if the size can't be determined. It also recovers the color space of the image, or null if it can't be determined.

Parameters
is the InputStream containing the image data
Returns
  • the metadata of the image

public static int getPixelSizeForBitmapConfig (Bitmap.Config bitmapConfig)

Returns the amount of bytes used by a pixel in a specific android.graphics.Bitmap.Config

Parameters
bitmapConfig the android.graphics.Bitmap.Config for which the size in byte will be returned

public static int getSizeInByteForBitmap (int width, int height, Bitmap.Config bitmapConfig)

Returns the size in byte of an image with specific size and android.graphics.Bitmap.Config

Parameters
width the width of the image
height the height of the image
bitmapConfig the android.graphics.Bitmap.Config for which the size in byte will be returned

public static int getSizeInBytes (Bitmap bitmap)

Returns
  • size in bytes of the underlying bitmap