Skip to content

ImageUtils

Shanti Ranjan Das edited this page Jan 24, 2020 · 2 revisions
  • generateBitmapFromLayout(context: Context, layoutId: Int): Bitmap
    Method to generate Bitmap from layout.

  • getResizedBitmap(image: Bitmap, maxSize: Int): Bitmap
    Reduces the size of the bitmap image.

  • reduceBitmap(image: Bitmap, reduce: Int): Bitmap
    Reduces the size of the bitmap image to provided size in KB.

  • getCircleBitmap(context: Context, bitmap_image: Bitmap): Bitmap
    Converts and bitmap image to circular bitmap.

  • toBitmap(context: Context, @DrawableRes resId: Int): Bitmap?
    Drawable to generate bitmap.

  • toBitmap(drawable: Drawable): Bitmap?
    Pass the drawable to get bitmap.

  • getResourceId(context: Context, resName: String): Int
    Get id of drawable from name.

  • getMutatedDrawable(context: Context, @DrawableRes resId: Int): Drawable?
    Get id of drawable from name.

  • getTintedDrawable(context: Context, @DrawableRes resId: Int, @ColorInt color: Int): Drawable?
    Get tinted drawable.

  • getTintedDrawable(drawable: Drawable, @ColorInt color: Int): Drawable?
    Get tinted drawable

  • getResizedDrawable(context: Context, drawable: Drawable, sizeInDp: Float): Drawable?
    Get resized drawable.

  • toDrawable(context: Context, bitmap: Bitmap): Drawable?
    Bitmap to drawable.

  • resizeImage(imageData: ByteArray, targetWidth: Int, targetHeight: Int): Bitmap
    method to resize an image to a specified width and height.

  • resizeImageMaintainAspectRatio(imageData: ByteArray, shorterSideTarget: Int): Bitmap
    Resize image by maintaining the aspect Ratio.

  • getDimensions(imageData: ByteArray): Pair<Int, Int>
    Get Dimentions of Image.

  • calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int
    Calculate sample size of Image.

  • tileBackground(ctx: Context, viewId: Int, resIdOfTile: Int)
    Tiles the background of a view.

  • tileBackground(ctx: Context, layoutId: Int, viewToTileBg: View, resIdOfTile: Int)
    Tiles the background of a layout.

Clone this wiki locally