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

相关推荐
懒人村杂货铺7 小时前
Android BLE 扫描完整实战
android
TeleostNaCl10 小时前
如何安装 Google 通用的驱动以便使用 ADB 和 Fastboot 调试(Bootloader)设备
android·经验分享·adb·android studio·android-studio·android runtime
fatiaozhang952710 小时前
中国移动浪潮云电脑CD1000-系统全分区备份包-可瑞芯微工具刷机-可救砖
android·网络·电脑·电视盒子·刷机固件·机顶盒刷机
低调小一11 小时前
Swift 语法学习指南 - 与 Kotlin 对比
微信·kotlin·swift
2501_9159184111 小时前
iOS 开发全流程实战 基于 uni-app 的 iOS 应用开发、打包、测试与上架流程详解
android·ios·小程序·https·uni-app·iphone·webview
lichong95111 小时前
【混合开发】vue+Android、iPhone、鸿蒙、win、macOS、Linux之dist打包发布在Android工程asserts里
android·vue.js·iphone
Android出海12 小时前
Android 15重磅升级:16KB内存页机制详解与适配指南
android·人工智能·新媒体运营·产品运营·内容运营
一只修仙的猿12 小时前
毕业三年后,我离职了
android·面试
编程乐学12 小时前
安卓非原创--基于Android Studio 实现的新闻App
android·ide·android studio·移动端开发·安卓大作业·新闻app
雅雅姐13 小时前
Android14 init.rc中on boot阶段操作4
android