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

相关推荐
似水明俊德1 小时前
15-C#
android·开发语言·c#
阿拉斯攀登1 小时前
第 19 篇 驱动性能优化与功耗优化实战
android·驱动开发·瑞芯微·嵌入式驱动·安卓驱动
91刘仁德3 小时前
C++ 内存管理
android·c语言·数据结构·c++·经验分享·笔记·算法
小强开学前3 小时前
自定义 Drawable 实现任意高度纯圆角背景及玻璃效果
android
秃了也弱了。3 小时前
ElasticSearch:优化案例实战解析(持续更新)
android·java·elasticsearch
恋猫de小郭4 小时前
Kotlin 在 2.0 - 2.3 都更新了什么特性,一口气带你看完这两年 Kotlin 更新
android·前端·flutter
墨狂之逸才4 小时前
React Native 移动项目目录导致的 Android 编译失败问题及解决方案
android·react native
feng一样的男子4 小时前
住在手机里的“小龙虾” (OpenClaw):接入本地模型,解决记忆“装死”顽疾
android·ai·智能手机·openclaw
hongtianzai5 小时前
MySQL中between and的基本用法
android·数据库·mysql
Zender Han6 小时前
Flutter Bloc / Cubit 最新详解与实战指南(2026版)
android·flutter·ios