Skip to content

Image Helper

farimarwat edited this page Sep 12, 2023 · 3 revisions

ImageHelper is an extension for Document Scanner SDK to edit image with super easy method. Add signature, stickers etc

Implementation

implementation 'io.github.farimarwat:imagehelper:1.0'

Usage

Step 1: Prepare launcheractivity for result

 //Create launcher variable
lateinit var mLauncherEditImage:ActivityResultLauncher<Intent>

void onCreate(bundle:Bundle){

//Initialize the launcher
val uri = ... //get uri to the image
//Open image activity for editing
mLauncherEditImage = registerForActivityResult(
            ActivityResultContracts.StartActivityForResult()
        ){
            if(it.resultCode == ImageEditor.RESULT_OK){
                val uri = it.data?.data
                //Here is your edited/resulted image uri
            }
        }
}

Step 2: Execute the launcher

val uri = ... //obtain a uri to an image which you want to edit
val intent = Intent(mContext, ImageEditor::class.java)

//set uri for intent and execute
intent.data = uri
mLauncherEditImage.launch(intent)

Actions

When activity for image editing is opened, you may found three actions to perform.

  • Add (to add a sticker)
  • Save (to save the image/done editing)
  • Clear (to clear signature only. It will clear signature drawn by finger)