How to enable Gallery Scan

The SDK allows you to decode barcodes from image files. It supports several image formats, including BMP, PNG, and JPG. 

                BarkoderHelper.scanImage(image, bkdConfig: bkdConfig, resultDelegate: self)
            

Here is an example of how you can access the photo library on your device and select and scan images from within the library

                extension ViewController: UIImagePickerControllerDelegate & UINavigationControllerDelegate {
   
  func presentImagePicker() {     
    let imagePicker = UIImagePickerController()
    imagePicker.delegate = self
    imagePicker.sourceType = .photoLibrary
    UINavigationBar.appearance().backgroundColor = .white
    UIBarButtonItem.appearance().tintColor = .black
    self.present(imagePicker, animated: true) {
      UINavigationBar.appearance().backgroundColor = .clear
      UIBarButtonItem.appearance().tintColor = .white
    }
  }

  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    picker.dismiss(animated: true, completion: nil)
     
    guard let image = info[.originalImage] as? UIImage else {
      return
    }
     
    var bkdConfig = BarkoderConfig()
     
      BarkoderHelper.applyConfigSettingsFromTemplate(bkdConfig, template: .gallery_scan) { config in
        bkdConfig = config
}
         
    BarkoderHelper.scanImage(image, bkdConfig: bkdConfig, resultDelegate: self)
     
  }
   
  func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    picker.dismiss(animated: true, completion: nil)
  }
   
}
            

History:

close