package com.syaroful.agrilinkvocpro.plant_disease_detection_feature.core.extention

import android.graphics.Bitmap
import androidx.core.graphics.createBitmap

fun cropToSquare(bitmap: Bitmap?): Bitmap {
    if (bitmap == null) {
        return createBitmap(100, 100)
    } else {
        val dimension = minOf(bitmap.width, bitmap.height)
        val xOffset = (bitmap.width - dimension) / 2
        val yOffset = (bitmap.height - dimension) / 2
        return Bitmap.createBitmap(bitmap, xOffset, yOffset, dimension, dimension)
    }
}