当前位置: 首页 > 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

相关文章:

  • Xcode 编译速度慢是什么原因?如何提高编译速度?
  • 太阳系三体模拟器
  • PHP序列化总结1--序列化和反序列化的基础知识
  • UEFI模拟环境搭建——windows+EDKII
  • TiDB 7.1 多租户在中泰证券中的应用
  • Django框架:入门指南与常用命令
  • 状态模式-概述
  • 网络交换机端口管理会面临的问题
  • 在线客服选择要点分析:如何挑选适合您需求的客服解决方案
  • Zookeeper-Zookeeper应用场景实战(二)
  • ElementUI的Table组件行合并上手指南
  • 玩转MYSQL|详细分析mysql-MGR集群搭建
  • 基于SpringBoot的客户关系管理系统
  • 为什么深度学习神经网络可以学习任何东西
  • SElinux工作原理简介并演示chcon、semanage、restorecon的使用方法
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 【前端学习】-粗谈选择器
  • 0基础学习移动端适配
  • 4个实用的微服务测试策略
  • Android开源项目规范总结
  • canvas 高仿 Apple Watch 表盘
  • create-react-app项目添加less配置
  • crontab执行失败的多种原因
  • CSS中外联样式表代表的含义
  • gf框架之分页模块(五) - 自定义分页
  • Iterator 和 for...of 循环
  • JavaScript标准库系列——Math对象和Date对象(二)
  • Python 反序列化安全问题(二)
  • Sequelize 中文文档 v4 - Getting started - 入门
  • Terraform入门 - 1. 安装Terraform
  • vue和cordova项目整合打包,并实现vue调用android的相机的demo
  • Wamp集成环境 添加PHP的新版本
  • 从PHP迁移至Golang - 基础篇
  • 面试遇到的一些题
  • 如何学习JavaEE,项目又该如何做?
  • 数据仓库的几种建模方法
  • 写给高年级小学生看的《Bash 指南》
  • 职业生涯 一个六年开发经验的女程序员的心声。
  • mysql面试题分组并合并列
  • scrapy中间件源码分析及常用中间件大全
  • 国内开源镜像站点
  • ​【C语言】长篇详解,字符系列篇3-----strstr,strtok,strerror字符串函数的使用【图文详解​】
  • ​力扣解法汇总1802. 有界数组中指定下标处的最大值
  • "无招胜有招"nbsp;史上最全的互…
  • #{}和${}的区别是什么 -- java面试
  • #if 1...#endif
  • #单片机(TB6600驱动42步进电机)
  • ()、[]、{}、(())、[[]]等各种括号的使用
  • (MonoGame从入门到放弃-1) MonoGame环境搭建
  • (代码示例)使用setTimeout来延迟加载JS脚本文件
  • (二)【Jmeter】专栏实战项目靶场drupal部署
  • (六)Hibernate的二级缓存
  • (三)c52学习之旅-点亮LED灯
  • (十)DDRC架构组成、效率Efficiency及功能实现
  • (五)网络优化与超参数选择--九五小庞