Android transform旋转rotate圆角矩形图roundedCorners,Kotlin

Android transform旋转rotate圆角矩形图roundedCorners,Kotlin

Kotlin 复制代码
import android.graphics.Bitmap
import android.os.Bundle
import android.util.Log
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.TransformationUtils

class MainActivity : AppCompatActivity() {
    private val TAG = "fly/${this::class.simpleName}"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val imageView = findViewById<ImageView>(R.id.image)

        GlideApp.with(this)
            .load(R.mipmap.pic2)
            .transform(RotateRoundedCorners())
            .override(500, 500)
            .into(imageView)
    }

    inner class RotateRoundedCorners : CenterCrop() {
        override fun transform(
            pool: BitmapPool,
            toTransform: Bitmap,
            outWidth: Int,
            outHeight: Int
        ): Bitmap {
            Log.d(TAG, "$outWidth $outHeight ${toTransform.byteCount}")

            //先变换成圆角矩形(50)。
            val bmp = TransformationUtils.roundedCorners(pool, toTransform, 50)

            //再逆向旋转30度。
            return TransformationUtils.rotateImage(bmp, -30)
        }
    }
}

Glide transform CircleCrop()圆图,Kotlin-CSDN博客文章浏览阅读369次。文章浏览阅读1.2w次。引入: implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'Android标准Glide加载圆形图和圆角矩形图_android glide加载圆角-CSDN博客。Glide transform CircleCrop()圆图,Kotlin。https://blog.csdn.net/zhangphil/article/details/134147774

相关推荐
代码s贝多芬的音符5 小时前
ios android 小程序 蓝牙 CRC16_MODBUS
android·ios·小程序
2501_915918417 小时前
iOS 混淆实战 多工具组合完成 IPA 混淆、加固与工程化落地(iOS混淆|IPA加固|无源码混淆|Ipa Guard|Swift Shield)
android·ios·小程序·https·uni-app·iphone·webview
雨白7 小时前
让协程更健壮:全面的异常处理策略
android·kotlin
Jeled8 小时前
AI: 生成Android自我学习路线规划与实战
android·学习·面试·kotlin
消失的旧时光-19439 小时前
@JvmStatic 的作用
java·开发语言·kotlin
游戏开发爱好者810 小时前
如何系统化掌握 iOS 26 App 耗电管理,多工具协作
android·macos·ios·小程序·uni-app·cocoa·iphone
shaominjin12310 小时前
android在sd卡中可以mkdir, 但是不可以createNewFile
android·开发语言·python
AI科技星10 小时前
垂直原理:宇宙的沉默法则与万物运动的终极源头
android·服务器·数据结构·数据库·人工智能
wb0430720111 小时前
如何开发一个 IDEA 插件通过 Ollama 调用大模型为方法生成仙侠风格的注释
人工智能·语言模型·kotlin·intellij-idea
用户416596736935511 小时前
Kotlin Coroutine Flow 深度解析:剖析 `flowOn` 与上下文切换的奥秘
android