ImageUtils

class ImageUtils
    author: Blankj
    blog  : http://blankj.com
    time  : 2016/08/12
    desc  : utils about image

Functions

addCircleBorder
Link copied to clipboard
open fun addCircleBorder(src: Bitmap, @IntRange(from = 1borderSize: Int, @ColorInt() color: Int): Bitmap
Return the round bitmap with border.
open fun addCircleBorder(src: Bitmap, @IntRange(from = 1borderSize: Int, @ColorInt() color: Int, recycle: Boolean): Bitmap
Return the round bitmap with border.
addCornerBorder
Link copied to clipboard
open fun addCornerBorder(src: Bitmap, @IntRange(from = 1borderSize: Int, @ColorInt() color: Int, @FloatRange(from = 0cornerRadius: Float): Bitmap
Return the round corner bitmap with border.
open fun addCornerBorder(src: Bitmap, @IntRange(from = 1borderSize: Int, @ColorInt() color: Int, @FloatRange(from = 0cornerRadius: Float, recycle: Boolean): Bitmap
Return the round corner bitmap with border.
addImageWatermark
Link copied to clipboard
open fun addImageWatermark(src: Bitmap, watermark: Bitmap, x: Int, y: Int, alpha: Int): Bitmap
Return the bitmap with image watermarking.
open fun addImageWatermark(src: Bitmap, watermark: Bitmap, x: Int, y: Int, alpha: Int, recycle: Boolean): Bitmap
Return the bitmap with image watermarking.
addReflection
Link copied to clipboard
open fun addReflection(src: Bitmap, reflectionHeight: Int): Bitmap
Return the bitmap with reflection.
open fun addReflection(src: Bitmap, reflectionHeight: Int, recycle: Boolean): Bitmap
Return the bitmap with reflection.
addTextWatermark
Link copied to clipboard
open fun addTextWatermark(src: Bitmap, content: String, textSize: Int, @ColorInt() color: Int, x: Float, y: Float): Bitmap
Return the bitmap with text watermarking.
open fun addTextWatermark(src: Bitmap, content: String, textSize: Float, @ColorInt() color: Int, x: Float, y: Float, recycle: Boolean): Bitmap
Return the bitmap with text watermarking.
bitmap2Bytes
Link copied to clipboard
open fun bitmap2Bytes(bitmap: Bitmap, format: Bitmap.CompressFormat): Array<Byte>
Bitmap to bytes.
bitmap2Drawable
Link copied to clipboard
open fun bitmap2Drawable(bitmap: Bitmap): Drawable
Bitmap to drawable.
bytes2Bitmap
Link copied to clipboard
open fun bytes2Bitmap(bytes: Array<Byte>): Bitmap
Bytes to bitmap.
bytes2Drawable
Link copied to clipboard
open fun bytes2Drawable(bytes: Array<Byte>): Drawable
Bytes to drawable.
clip
Link copied to clipboard
open fun clip(src: Bitmap, x: Int, y: Int, width: Int, height: Int): Bitmap
Return the clipped bitmap.
open fun clip(src: Bitmap, x: Int, y: Int, width: Int, height: Int, recycle: Boolean): Bitmap
Return the clipped bitmap.
compressByQuality
Link copied to clipboard
open fun compressByQuality(src: Bitmap, @IntRange(from = 0, to = 100quality: Int): Bitmap
Return the compressed bitmap using quality.
open fun compressByQuality(src: Bitmap, maxByteSize: Long): Bitmap
Return the compressed bitmap using quality.
open fun compressByQuality(src: Bitmap, @IntRange(from = 0, to = 100quality: Int, recycle: Boolean): Bitmap
Return the compressed bitmap using quality.
open fun compressByQuality(src: Bitmap, maxByteSize: Long, recycle: Boolean): Bitmap
Return the compressed bitmap using quality.
compressBySampleSize
Link copied to clipboard
open fun compressBySampleSize(src: Bitmap, sampleSize: Int): Bitmap
Return the compressed bitmap using sample size.
open fun compressBySampleSize(src: Bitmap, sampleSize: Int, recycle: Boolean): Bitmap
Return the compressed bitmap using sample size.
open fun compressBySampleSize(src: Bitmap, maxWidth: Int, maxHeight: Int): Bitmap
Return the compressed bitmap using sample size.
open fun compressBySampleSize(src: Bitmap, maxWidth: Int, maxHeight: Int, recycle: Boolean): Bitmap
Return the compressed bitmap using sample size.
compressByScale
Link copied to clipboard
open fun compressByScale(src: Bitmap, scaleWidth: Float, scaleHeight: Float): Bitmap
Return the compressed bitmap using scale.
open fun compressByScale(src: Bitmap, newWidth: Int, newHeight: Int): Bitmap
Return the compressed bitmap using scale.
open fun compressByScale(src: Bitmap, scaleWidth: Float, scaleHeight: Float, recycle: Boolean): Bitmap
Return the compressed bitmap using scale.
open fun compressByScale(src: Bitmap, newWidth: Int, newHeight: Int, recycle: Boolean): Bitmap
Return the compressed bitmap using scale.
drawable2Bitmap
Link copied to clipboard
open fun drawable2Bitmap(drawable: Drawable): Bitmap
Drawable to bitmap.
drawable2Bytes
Link copied to clipboard
open fun drawable2Bytes(drawable: Drawable, format: Bitmap.CompressFormat): Array<Byte>
Drawable to bytes.
drawColor
Link copied to clipboard
open fun drawColor(@NonNull() src: Bitmap, @ColorInt() color: Int): Bitmap
Return the bitmap with the specified color.
open fun drawColor(@NonNull() src: Bitmap, @ColorInt() color: Int, recycle: Boolean): Bitmap
Return the bitmap with the specified color.
fastBlur
Link copied to clipboard
open fun fastBlur(src: Bitmap, @FloatRange(from = 0, to = 1, fromInclusive = falsescale: Float, @FloatRange(from = 0, to = 25, fromInclusive = falseradius: Float): Bitmap
Return the blur bitmap fast.
open fun fastBlur(src: Bitmap, @FloatRange(from = 0, to = 1, fromInclusive = falsescale: Float, @FloatRange(from = 0, to = 25, fromInclusive = falseradius: Float, recycle: Boolean): Bitmap
Return the blur bitmap fast.
getBitmap
Link copied to clipboard
open fun getBitmap(@DrawableRes() resId: Int): Bitmap
Return bitmap.
open fun getBitmap(file: File): Bitmap
Return bitmap.
open fun getBitmap(fd: FileDescriptor): Bitmap
Return bitmap.
open fun getBitmap(is: InputStream): Bitmap
Return bitmap.
open fun getBitmap(filePath: String): Bitmap
Return bitmap.
open fun getBitmap(data: Array<Byte>, offset: Int): Bitmap
Return bitmap.
open fun getBitmap(@DrawableRes() resId: Int, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
open fun getBitmap(file: File, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
open fun getBitmap(fd: FileDescriptor, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
open fun getBitmap(is: InputStream, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
open fun getBitmap(filePath: String, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
open fun getBitmap(data: Array<Byte>, offset: Int, maxWidth: Int, maxHeight: Int): Bitmap
Return bitmap.
getImageType
Link copied to clipboard
open fun getImageType(file: File): String
Return the type of image.
open fun getImageType(filePath: String): String
Return the type of image.
getRotateDegree
Link copied to clipboard
open fun getRotateDegree(filePath: String): Int
Return the rotated degree.
isImage
Link copied to clipboard
open fun isImage(file: File): Boolean
Return whether it is a image according to the file name.
open fun isImage(filePath: String): Boolean
Return whether it is a image according to the file name.
renderScriptBlur
Link copied to clipboard
open fun renderScriptBlur(src: Bitmap, @FloatRange(from = 0, to = 25, fromInclusive = falseradius: Float): Bitmap
Return the blur bitmap using render script.
open fun renderScriptBlur(src: Bitmap, @FloatRange(from = 0, to = 25, fromInclusive = falseradius: Float, recycle: Boolean): Bitmap
Return the blur bitmap using render script.
rotate
Link copied to clipboard
open fun rotate(src: Bitmap, degrees: Int, px: Float, py: Float): Bitmap
Return the rotated bitmap.
open fun rotate(src: Bitmap, degrees: Int, px: Float, py: Float, recycle: Boolean): Bitmap
Return the rotated bitmap.
save
Link copied to clipboard
open fun save(src: Bitmap, file: File, format: Bitmap.CompressFormat): Boolean
Save the bitmap.
open fun save(src: Bitmap, filePath: String, format: Bitmap.CompressFormat): Boolean
Save the bitmap.
open fun save(src: Bitmap, file: File, format: Bitmap.CompressFormat, recycle: Boolean): Boolean
Save the bitmap.
open fun save(src: Bitmap, filePath: String, format: Bitmap.CompressFormat, recycle: Boolean): Boolean
Save the bitmap.
scale
Link copied to clipboard
open fun scale(src: Bitmap, scaleWidth: Float, scaleHeight: Float): Bitmap
Return the scaled bitmap
open fun scale(src: Bitmap, newWidth: Int, newHeight: Int): Bitmap
Return the scaled bitmap.
open fun scale(src: Bitmap, scaleWidth: Float, scaleHeight: Float, recycle: Boolean): Bitmap
Return the scaled bitmap
open fun scale(src: Bitmap, newWidth: Int, newHeight: Int, recycle: Boolean): Bitmap
Return the scaled bitmap.
skew
Link copied to clipboard
open fun skew(src: Bitmap, kx: Float, ky: Float): Bitmap
Return the skewed bitmap.
open fun skew(src: Bitmap, kx: Float, ky: Float, recycle: Boolean): Bitmap
Return the skewed bitmap.
open fun skew(src: Bitmap, kx: Float, ky: Float, px: Float, py: Float): Bitmap
Return the skewed bitmap.
open fun skew(src: Bitmap, kx: Float, ky: Float, px: Float, py: Float, recycle: Boolean): Bitmap
Return the skewed bitmap.
stackBlur
Link copied to clipboard
open fun stackBlur(src: Bitmap, radius: Int): Bitmap
Return the blur bitmap using stack.
open fun stackBlur(src: Bitmap, radius: Int, recycle: Boolean): Bitmap
Return the blur bitmap using stack.
toAlpha
Link copied to clipboard
open fun toAlpha(src: Bitmap): Bitmap
Return the alpha bitmap.
open fun toAlpha(src: Bitmap, recycle: Boolean): Bitmap
Return the alpha bitmap.
toGray
Link copied to clipboard
open fun toGray(src: Bitmap): Bitmap
Return the gray bitmap.
open fun toGray(src: Bitmap, recycle: Boolean): Bitmap
Return the gray bitmap.
toRound
Link copied to clipboard
open fun toRound(src: Bitmap): Bitmap
Return the round bitmap.
open fun toRound(src: Bitmap, recycle: Boolean): Bitmap
Return the round bitmap.
open fun toRound(src: Bitmap, @IntRange(from = 0borderSize: Int, @ColorInt() borderColor: Int): Bitmap
Return the round bitmap.
open fun toRound(src: Bitmap, @IntRange(from = 0borderSize: Int, @ColorInt() borderColor: Int, recycle: Boolean): Bitmap
Return the round bitmap.
toRoundCorner
Link copied to clipboard
open fun toRoundCorner(src: Bitmap, radius: Float): Bitmap
Return the round corner bitmap.
open fun toRoundCorner(src: Bitmap, radius: Float, recycle: Boolean): Bitmap
Return the round corner bitmap.
open fun toRoundCorner(src: Bitmap, radius: Float, @IntRange(from = 0borderSize: Int, @ColorInt() borderColor: Int): Bitmap
Return the round corner bitmap.
open fun toRoundCorner(src: Bitmap, radius: Float, @IntRange(from = 0borderSize: Int, @ColorInt() borderColor: Int, recycle: Boolean): Bitmap
Return the round corner bitmap.
view2Bitmap
Link copied to clipboard
open fun view2Bitmap(view: View): Bitmap
View to bitmap.