Android ExifInterface rotationDegrees图旋转角度,Kotlin

Android ExifInterface rotationDegrees图旋转角度,Kotlin

Kotlin 复制代码
import android.media.ThumbnailUtils
import android.os.Bundle
import android.util.Log
import android.util.Size
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.exifinterface.media.ExifInterface
import java.io.File

class MainActivity : AppCompatActivity() {
    companion object {
        const val TAG = "fly/MainActivity"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val img1 = findViewById<ImageView>(R.id.img1)
        val img2 = findViewById<ImageView>(R.id.img2)

        val filePath = "/storage/emulated/0/data/heic/IMG_1587.HEIC"

        var t = System.currentTimeMillis()
        val bmp1 = ThumbnailUtils.createImageThumbnail(File(filePath), Size(200, 200), null)
        Log.d(TAG, "decodeFile 耗时=${System.currentTimeMillis() - t}ms")

        img1.setImageBitmap(bmp1)

        img2.setImageBitmap(bmp1)

        t = System.currentTimeMillis()
        val exifInterface = ExifInterface(filePath)
        Log.d(TAG, "rotationDegrees=${exifInterface.rotationDegrees} 耗时=${System.currentTimeMillis() - t}ms")

        val degree = exifInterface.rotationDegrees * (-1f)
        if (degree != 0f) {
            img2.rotation = degree
        }
    }
}

注意:

复制代码
val exifInterface = ExifInterface(filePath)

最终是要FileInputStream读文件,这是一个耗时IO,通常需要几十ms以上,有一定性能开销。

Android多张图片rotation旋转角度叠加/重叠堆放_android 图片无规则叠放-CSDN博客文章浏览阅读810次。《Android大图片之变换缩略图,以及对原始大图片按照指定宽、高裁剪成缩略图》在Android的ImageView加载图像资源过程中,出于性能和内存开销的需要,有时候需要把一个原始的超大图片按照一定比例等比例缩放成较小的缩略图,或者需要把原始的超大图片,裁剪成指定宽高值的较小图片,针对这种开发需求,可以使用Android SDK自身提供的工具类:ThumbnailUtils完成。Android旋转动画rotate动画,xml配置set实现_android xml 旋转动画-CSDN博客。_android 图片无规则叠放https://blog.csdn.net/zhangphil/article/details/134065191

Android ValueAnimator ImageView animate() rotation,Kotlin-CSDN博客文章浏览阅读788次,点赞7次,收藏4次。Android ValueAnimator属性动画ObjectAnimator使View颜色渐变,Kotlin。_view动画 渐变。Android ValueAnimator属性动画ObjectAnimator使View颜色渐变,Kotlin_view动画 渐变-CSDN博客。https://blog.csdn.net/zhangphil/article/details/145289647

相关推荐
毕设源码-朱学姐18 分钟前
【开题答辩全过程】以 基于安卓的教师上课辅助系统为例,包含答辩的问题和答案
android
诸神黄昏EX2 小时前
Android Safety 系列专题【篇二:AVB签名】
android
2601_949543012 小时前
Flutter for OpenHarmony垃圾分类指南App实战:意见反馈实现
android·flutter
urkay-2 小时前
Android 中实现 HMAC-SHA256
android·开发语言·python
YIN_尹2 小时前
【MySQL】增删查改的艺术——数据库CRUD完全指南(下)
android·数据库·mysql
m0_748233173 小时前
PHP8.0新特性全解析
android
一起养小猫3 小时前
Flutter for OpenHarmony 实战:从零开发一款五子棋游戏
android·前端·javascript·flutter·游戏·harmonyos
●VON3 小时前
从像素到语义:React Native Text 组件在 OpenHarmony 上的渲染哲学与工程实现
android·react native·react.js
henysugar3 小时前
Android studio编译aidl若干问题记录
android·ide·android studio·aidl
阿斌_bingyu7093 小时前
FastAdmin 混合式语言包添加繁体中文(zh-tw)完整教程
android·ide