我正在开发一个选择伤口图像并将其显示在应用程序屏幕上的应用程序。这样,用户就可以标记伤口的感兴趣区域,以便以后算法可以识别和处理感兴趣的区域。我正在使用 lib 实现 'com.github.gcacace: signature-pad: 1.2.1' 来划分区域,然后保存屏幕的“printscreen”,这样我就可以将标记与图像一起保存伤口。我希望图像看起来如何
但是,我想根据伤口的图像切割打印屏幕发送到服务器处理图像。有人可以帮我剪下标记后的伤口图像。
private fun saveImage(myBitmap: Bitmap?): String? {
try {
// image naming and path to include sd card appending name you choose for file
val mPath = Environment.getExternalStorageDirectory().toString() + "/imagesignature.jpg"
// create bitmap screen capture
val v1 = window.decorView.rootView
v1.isDrawingCacheEnabled = true
val bitmap = Bitmap.createBitmap(v1.drawingCache)
v1.isDrawingCacheEnabled = false
val imageFile = File(mPath)
val outputStream = FileOutputStream(imageFile)
val quality = 100
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream)
outputStream.flush()
outputStream.close()
//setting screenshot in imageview
val filePath = imageFile.path
val ssbitmap = BitmapFactory.decodeFile(imageFile.absolutePath)
imagem.setImageBitmap(ssbitmap)
} catch (e: Throwable) {
// Several error may come out with file handling or DOM
e.printStackTrace()
}
return ""
}