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

相关推荐
天燹30 分钟前
Qt 6 嵌入 Android 原生应用完整教程
android·开发语言·qt
美狐美颜sdk39 分钟前
企业级直播美颜SDK与动态贴纸SDK开发技术方案拆解与落地实践
android·人工智能·计算机视觉·第三方美颜sdk·人脸美型sdk
低调小一1 小时前
Kotlin 2025–2026 客户端开发路线:语言升级 × 跨端落地 × AI Agent 入门
开发语言·人工智能·kotlin
PwnGuo2 小时前
Android逆向:在 Unidbg 中解决 native 函数内调用 Java 方法的报错
android·java·python
Kratzdisteln2 小时前
【1902】优化后的三路径学习系统
android·学习
Digitally3 小时前
如何将文件从 iPhone 传输到 Android
android·ios·iphone
a3158238063 小时前
Android修改调试屏幕的选择方向
android·adb·屏幕旋转
超级数据查看器3 小时前
超级数据查看器 更新日志(包含的功能)
android·java·数据库·sqlite·安卓
AiFlutter3 小时前
Flutter-Android不能通过apply script方法应用Gradle插件
android·flutter
2501_915106323 小时前
iOS 抓包工具实战实践指南,围绕代理抓包、数据流抓包和拦截器等常见工具
android·ios·小程序·https·uni-app·iphone·webview