Car*_*ego 2 java mobile android kotlin
我正在开发一个应用程序,该应用程序选择伤口图像并将其显示在应用程序屏幕上。以此,用户标记伤口的感兴趣区域,以便稍后算法可以识别和处理感兴趣区域。我正在使用 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 ""
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我仍然是一个学习者,所以为了一种简单的裁剪图像的方法,我建议使用这个库:
https://github.com/ArthurHub/Android-Image-Cropper
您可以在此处根据需要裁剪图像并将图像存储在服务器上
| 归档时间: |
|
| 查看次数: |
178 次 |
| 最近记录: |