INNER CODE UNIT · Kotlin

cropImageUri

fumiama/copymanga · app/src/main/java/top/fumiama/copymanga/MainActivity.kt:443

    private fun cropImageUri() {
        val op = UCrop.Options()
        val r = navhbg.width.toFloat() / navhbg.height.toFloat()
        Log.d("MyMain", "Img info: (${navhbg.width}, ${navhbg.height})")
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            op.setCompressionFormat(Bitmap.CompressFormat.WEBP_LOSSY)
        } else {
            op.setCompressionFormat(Bitmap.CompressFormat.WEBP)
        }
        op.setStatusBarColor(resources.getColor(R.color.colorPrimaryDark, theme))
        op.setToolbarColor(resources.getColor(R.color.colorPrimary, theme))
        op.setActiveControlsWidgetColor(resources.getColor(R.color.colorAccent, theme))
        cropLauncher.launch(UCrop.of(headPic.toUri(), headPic.toUri())
            .withAspectRatio(r, 1F)
            .withMaxResultSize(navhbg.width, navhbg.height)
            .withOptions(op)
            .getIntent(this))
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…