当前位置: 首页 > news >正文

Android Matrix画布Canvas旋转Rotate,Kotlin

Android Matrix画布Canvas旋转Rotate,Kotlin

    private fun f1() {val originBmp = BitmapFactory.decodeResource(resources, R.mipmap.pic).copy(Bitmap.Config.ARGB_8888, true)val newBmp = Bitmap.createBitmap(originBmp.width, originBmp.height, Bitmap.Config.ARGB_8888)val canvas = Canvas(newBmp)val matrix = Matrix()canvas.concat(matrix)matrix.setRotate(20f) //默认左上角(0,0)为旋转点//把原图绘制在画布Canvas上canvas.drawBitmap(originBmp, matrix, null)val paint = Paint(Paint.ANTI_ALIAS_FLAG)paint.color = Color.REDpaint.textSize = 60fpaint.style = Paint.Style.FILLpaint.textAlign = Paint.Align.LEFTval x = 20fval y = 100fcanvas.drawText("fly", x, y, paint)iv1?.setImageBitmap(newBmp)}private fun f2() {val originBmp = BitmapFactory.decodeResource(resources, R.mipmap.pic).copy(Bitmap.Config.ARGB_8888, true)val newBmp = Bitmap.createBitmap(originBmp.width, originBmp.height, Bitmap.Config.ARGB_8888)val canvas = Canvas(newBmp)val matrix = Matrix()canvas.concat(matrix)//围绕图片中心旋转matrix.setRotate(20f, (originBmp.width / 2).toFloat(), (originBmp.height / 2).toFloat())//把原图绘制在画布Canvas上canvas.drawBitmap(originBmp, matrix, null)val paint = Paint(Paint.ANTI_ALIAS_FLAG)paint.color = Color.REDpaint.textSize = 60fpaint.style = Paint.Style.FILLpaint.textAlign = Paint.Align.LEFTval x = 20fval y = 100fcanvas.drawText("fly", x, y, paint)iv2?.setImageBitmap(newBmp)}

Android Matrix画布Canvas缩放scale,Kotlin-CSDN博客文章浏览阅读116次,点赞3次,收藏3次。文章浏览阅读9.6k次。文章浏览阅读1.8k次。/*Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth();Android Material Design :LinearLayoutCompat添加分割线divider_linearlayout 分割线-CSDN博客。https://blog.csdn.net/zhangphil/article/details/135114661

Android画布Canvas绘图scale & translate,Kotlin-CSDN博客文章浏览阅读447次,点赞4次,收藏11次。文章浏览阅读9.6k次。文章浏览阅读1.8k次。/*Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth();Android Material Design :LinearLayoutCompat添加分割线divider_linearlayout 分割线-CSDN博客。https://blog.csdn.net/zhangphil/article/details/134930229

http://www.lryc.cn/news/270665.html

相关文章:

  • 私有部署ELK,搭建自己的日志中心(三)-- Logstash的安装与使用
  • 2023就这样过去了,2024会更好吗?
  • SpringBoot加载配置的6种方式
  • 大语言模型(LLM)训练平台与工具
  • docker配置buildx插件
  • mysql 空间函数
  • vscode调试 反汇编c/c++ 查看汇编代码gdb/lldb
  • 总结项目中oauth2模块的配置流程及实际业务oauth2认证记录(Spring Security)
  • 传感器原理与应用复习
  • 蓝桥杯python比赛历届真题99道经典练习题 (8-12)
  • 八个理由:从java8升级到Java17
  • 使用poi将pptx文件转为图片详解
  • 【微服务】springboot整合skywalking使用详解
  • electron——查看electron的版本(代码片段)
  • 【Electron】富文本编辑器之文本粘贴
  • 【哈希数组】697. 数组的度
  • GO语言工具函数库--Lancet
  • 25、商城系统(七):商城项目基础功能pom.xml(重要),mybatis分页插件
  • 【Docker-Dev】Mac M2 搭建docker mysql
  • idea中终端Terminal页面输入命令git log后如何退出
  • 程序员必备IDEA插件,什么是是IDE?
  • SkyWalking UI 修改发布Nginx
  • 移动硬盘打不开怎么办?没有比这更好的办法了
  • [场景实现]:多选框与树形结构递归
  • 从0到1浅析Redis服务器反弹Shell那些事
  • JavaScript中alert、confrim、prompt的使用及区别【精选】
  • Docker Compose容器编排实战
  • 科技创新实验室数据管理优选:高效企业网盘推荐
  • 记录一次云服务器使用docker搭建kafka的过程
  • 微信小程序与vue区别