以前のリビジョンの文書です
// imageViewに画像を設定
image1.setImageResource(R.drawable.man)
// bitmapとして取り出す
val bitMan = BitmapFactory.decodeResource(resources,R.drawable.man)
// matrixを生成
val matrix = Matrix()
// 画像中心を基点に90度回転(角度、基点x、基点y)
matrix.setRotate(90f, (imageWidth/2).toFloat(),(imageHeight/2).toFloat())
// 画像縮小
matrix.preScale(0.5f, 0.5f)
// 元画像から90度回転、半分に縮小した画像を生成
val bitMan90 = Bitmap.createBitmap( bitMan, 0, 0,imageWidth, imageHeight, matrix, true)
// ImageViewに画像設定
image1.setImageBitmap(bitMan90)
Glide をインストールする
// build.gradle(project)
repositories {
mavenCentral()
google()
}
// build.gradle(app)
dependencies {
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
}
以下Glideの簡単な使い方
// ImageViewにgifを表示させるだけ
Glide.with(this).load(R.drawable.anime_test).into(image2)
// ネットから画像を取得する
// <uses-permission android:name="android.permission.INTERNET" />が必要
// httpは別途手間が必要...httpsだと簡単
Glide.with(this).load("https://ips.nekotype.com/wp-content/uploads/2017/05/eyechatch_default-150x150.jpg").into(image2)
// 画像の縁を丸くして表示する
Glide.with(this)
.load("https://ips.nekotype.com/wp-content/uploads/2017/05/eyechatch_default-150x150.jpg")
.apply(RequestOptions.bitmapTransform(RoundedCorners(30))) //←この一行追加
.into(image2)