display image resolution at the properties dialog

This commit is contained in:
tibbi
2016-10-16 16:19:34 +02:00
parent fd00b26f9b
commit b45e526fa7
9 changed files with 38 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.simplemobiletools.filepicker.models
import android.graphics.Bitmap
import android.graphics.BitmapFactory
class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) :
@ -22,6 +23,16 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
fun isImage(): Boolean {
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
return options.outWidth !== -1 && options.outHeight !== -1
BitmapFactory.decodeFile(path, options)
return options.outWidth != -1 && options.outHeight != -1
}
val resolution: String
get () {
val bitmap: Bitmap? = BitmapFactory.decodeFile(path)
if (bitmap == null)
return ""
return "${bitmap.width} x ${bitmap.height}"
}
}