项目作者: mtjin

项目描述 :
Library that draw on View and have some useful functions
高级语言: Kotlin
项目地址: git://github.com/mtjin/DrawView.git
创建时间: 2020-04-10T14:10:00Z
项目社区:https://github.com/mtjin/DrawView

开源协议:MIT License

下载


DrawView

platform



Library that draw on View and have some useful functions
It is useful for drawing and signature

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }

Dependency

Add this to your module’s build.gradle file (make sure the version matches the JitPack badge above):

  1. dependencies {
  2. ...
  3. implementation 'com.github.mtjin:DrawView:v1.0'
  4. }

Usage

There is also sample code in this repository. (https://github.com/mtjin/DrawView/tree/master/app)

To change pen color

  1. drawView.setPenColor(Color.parseColor("#D81B60"))

To change pen stroke width

  1. drawView.setStrokeWidth(20f)

To undo draw

  1. drawView.undo()

To redo draw

  1. drawView.redo()

To clear all draw

  1. drawView.clear()

To get Bitmap from only draw line of DrawView

  1. val bitmap = drawView.getBitmapDrawLine()
  2. imageView.setImageBitmap(bitmap)

To get Bitmap from DrawView

  1. val bitmap = drawView.getBitmap()
  2. imageView.setImageBitmap(bitmap)

Download File to gallery and get the Uri, it needs WRITE_EXTERNAL_STORAGE permission (drawVie file)

  1. drawView.saveFileDrawViewGetUri()
  2. //Only Download
  3. saveFileDrawView()

Download File to gallery and get the Uri, it needs WRITE_EXTERNAL_STORAGE permission (draw line file , background : whitecolor)

  1. drawView.saveFileDrawLineGetUri()
  2. //Only Download
  3. saveFileDrawLine()

To get Draw Path List

  1. drawView.getPathList()

To get Draw Point(x,y) List

  1. drawView.getPointList()

save image file second method

  1. val bitmap = drawImageView.getBitmap()
  2. var outStream: FileOutputStream? = null
  3. val sdCard: File = Environment.getExternalStorageDirectory()
  4. val dir = File(sdCard.absolutePath + "/DrawApp")
  5. dir.mkdirs()
  6. val fileName =
  7. String.format("%d.jpg", System.currentTimeMillis())
  8. val outFile = File(dir, fileName)
  9. outStream = FileOutputStream(outFile)
  10. bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream)
  11. outStream.flush()
  12. outStream.close()

It can also set by xml

  1. <com.mtjin.library.DrawView
  2. android:layout_width="wrap_content"
  3. app:pen_color="#4455B7"
  4. app:pen_stroke="30"
  5. android:layout_height="wrap_content"></com.mtjin.library.DrawView>

Sample

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

Images










Other My Libraries

BorderEditText

License

  1. MIT License
  2. Copyright (c) 2021 JackJackE
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.