private fun saveView(view: View, context: Context, num: Int) : File? {
val Path = Environment.getExternalStorageDirectory().absolutePath
val dirPath = "${Path}/allokal/signature"
var file : File? = null
val b = Bitmap.createBitmap(
view.width, view.height, Bitmap.Config.RGB_565
)
val writePermission = ActivityCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
if (writePermission == PackageManager.PERMISSION_GRANTED) {
if (b != null) {
try {
val f = File("$dirPath/allokal")
f.mkdir()
val f2 = File("$dirPath/allokal/$num.png")
val c = Canvas(b)
view.draw(c)
val fos = FileOutputStream(f2)
b.compress(Bitmap.CompressFormat.PNG, 100, fos)
fos.close()
file = f2
} catch (e: Exception) {
Log.e("testSaveView", "Exception: $e")
}
}
return file
}else{
return file
}
}
'MVC 게시판' 카테고리의 다른 글
[Spring boot] Rest API 전송 크기 설정 (0) | 2023.04.12 |
---|---|
Multipart 사용해보기 (0) | 2022.09.30 |
Mybatis Mapper.xml 사용하기 (0) | 2022.08.11 |
Oauth 카카오로그인 웹 (0) | 2022.01.10 |
Oauth 카카오 로그인 앱 (0) | 2022.01.10 |