Library that draw on View and have some useful functions
It is useful for drawing and signature
Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add this to your module's build.gradle
file (make sure the version matches the JitPack badge above):
dependencies {
...
implementation 'com.github.mtjin:DrawView:v1.0'
}
There is also sample code in this repository. (https://github.com/mtjin/DrawView/tree/master/app)
To change pen color
drawView.setPenColor(Color.parseColor("#D81B60"))
To change pen stroke width
drawView.setStrokeWidth(20f)
To undo draw
drawView.undo()
To redo draw
drawView.redo()
To clear all draw
drawView.clear()
To get Bitmap from only draw line of DrawView
val bitmap = drawView.getBitmapDrawLine()
imageView.setImageBitmap(bitmap)
To get Bitmap from DrawView
val bitmap = drawView.getBitmap()
imageView.setImageBitmap(bitmap)
Download File to gallery and get the Uri, it needs WRITE_EXTERNAL_STORAGE permission (drawVie file)
drawView.saveFileDrawViewGetUri()
//Only Download
saveFileDrawView()
Download File to gallery and get the Uri, it needs WRITE_EXTERNAL_STORAGE permission (draw line file , background : whitecolor)
drawView.saveFileDrawLineGetUri()
//Only Download
saveFileDrawLine()
To get Draw Path List
drawView.getPathList()
To get Draw Point(x,y) List
drawView.getPointList()
save image file second method
val bitmap = drawImageView.getBitmap()
var outStream: FileOutputStream? = null
val sdCard: File = Environment.getExternalStorageDirectory()
val dir = File(sdCard.absolutePath + "/DrawApp")
dir.mkdirs()
val fileName =
String.format("%d.jpg", System.currentTimeMillis())
val outFile = File(dir, fileName)
outStream = FileOutputStream(outFile)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream)
outStream.flush()
outStream.close()
It can also set by xml
<com.mtjin.library.DrawView
android:layout_width="wrap_content"
app:pen_color="#4455B7"
app:pen_stroke="30"
android:layout_height="wrap_content"/>
I also used this library for my app
Project: https://github.com/mtjin/VisionApp/tree/master/Real_VisionApp/VisionApp
Sample Video : https://www.youtube.com/watch?v=30-KBgfjirs&feature=youtu.be
MIT License
Copyright (c) 2021 JackJackE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.