get the display resolution when resizing bitmap
This commit is contained in:
parent
5f4532d8a7
commit
0fd3c0cc53
|
@ -2,10 +2,7 @@ package com.simplemobiletools.draw
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.*
|
||||||
import android.graphics.Canvas
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.Paint
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
@ -94,12 +91,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||||
|
|
||||||
fun drawBitmap(activity: Activity, path: String) {
|
fun drawBitmap(activity: Activity, path: String) {
|
||||||
Thread({
|
Thread({
|
||||||
|
val size = Point()
|
||||||
|
activity.windowManager.defaultDisplay.getSize(size)
|
||||||
mBackgroundBitmap = Glide.with(context)
|
mBackgroundBitmap = Glide.with(context)
|
||||||
.load(path)
|
.load(path)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.into(width, height)
|
.into(size.x, size.y)
|
||||||
.get()
|
.get()
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
invalidate()
|
invalidate()
|
||||||
|
|
Loading…
Reference in New Issue