Skip to content

Latest commit

 

History

History
292 lines (163 loc) · 8.85 KB

README.md

File metadata and controls

292 lines (163 loc) · 8.85 KB

This repository archieved. For active updates and latest version click.

Android Compression SDK

API and integration Details

This section will explain technical information regarding SDK. Mainly the SDK will expose two classes and two supporting classes.

  1. ImgHelper - Purpose of this class is to handle all imaging related operations
  2. CameraHelper - Handle the camera related operations. Basically, an activity.
  3. CameraSupport - Holds various configurations for camera.
  4. ImgException - Handle all exceptions on Image related operations on ImgHelper.

Based on the requirement any one or all classes can be used. And need to import those from the SDK.

import com.extrieve.quickcapture.sdk.ImgHelper;

import com.extrieve.quickcapture.sdk.CameraHelper;

import com.extrieve.quickcapture.sdk.CameraSupport; import com.extrieve.quickcapture.sdk.ImgException;

CameraHelper

This class will be implemented as an activity. This class can be initialized as intent.

Intent CameraIntent = new Intent(this,Class.forName("com.extrieve.quickcapture.sdk.CameraHelper")); UriphotoURI=Uri.parse(CameraSupport.CamConfigClass.OutputPath); getActivity().grantUriPermission(this.getPackageName(), photoURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) { CameraIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } startActivityForResult(CameraIntent,REQUEST_CODE_FILE_RETURN);

And result of cameraHelper activity can be collected as:

@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_FILE_RETURN && resultCode == Activity.RESULT_OK){ Boolean Status = (Boolean) data.getExtras().get("STATUS"); String Description = (String) data.getExtras().get("DESCRIPTION"); if(Status == false){ //Failed to capture finishActivity(REQUEST_CODE_FILE_RETURN); return; } FileCollection = (ArrayList<String>) data.getExtras().get("fileCollection"); //FileCollection //: will contains all capture images path as string finishActivity(REQUEST_CODE_FILE_RETURN); }

Camera Helper having a supporting class with static configuration

CameraSupport.CamConfigClass.** CamConfigClass :**contains various configurations as follows:

  1. OutputPath - To set the output directory in which the captured images will be saved. Base app should have rights to write to the provided path.

CameraSupport.CamConfigClass.OutputPath = "pass output path as string";

  1. MaxPage - To set the number of captures to do on each camera session. And this can also control whether the capture mode is single or multi i.e..,
  2. if MaxPage <= 0 / not set: means unlimited.If MaxPage >= 1: means limited.

CameraSupport.CamConfigClass.MaxPage = 0;

MaxPage <= 0: unlimited || >=1: limited || = 1 single shot mode

  1. ColorMode - To Set the capture color mode- supporting color and grayscale.

CameraSupport.CamConfigClass.ColorMode = 1; //1-RGB,2-GRAY

  1. CaptureReview - To Enable review for a capture session.

CameraSupport.CamConfigClass.CaptureReview = true/false; 2. DeviceInfo - Will share all general information about the device.

CameraSupport.CamConfigClass.DeviceInfo;

  1. LastLogInfo - Will share all error details from CameraHelper.Will contains the last caught errors from camera helper section.

CameraSupport.CamConfigClass.LastLogInfo;

  1. CaptureSound - To Enable camera capture sound.

CameraSupport.CamConfigClass.CaptureSound = true;

  1. UseDefaultCamera - Can Manually set the native camera for any camera2 API failed devices

CameraSupport.CamConfigClass.UseDefaultCamera = true;

  1. ShowCaptureCountAndLimit - Can enable/disable capture limit toast/message & captured number

CameraSupport.CamConfigClass.ShowCaptureCountAndLimit = true;

  1. EnableFlash - Enable Document capture specific flash control for SDK camera.

CameraSupport.CamConfigClass.EnableFlash = true;

CameraHelper class will be further optimized as part of the testing and development. Also there will be additional parameter options as well as license initialization as part of the SDK initialization process.

  1. SDKInfo - Contains all version related information on SDK.

CameraSupport.CamConfigClass.SDKInfo_;_

ImgHelper

Following are the options/methods available from class _ ImgHelper _

ImgHelper ImageHelper = new ImgHelper(this);

  1. SetImageQuality (ImageQuality value) - Set the Quality of the image, default Document_Quality is used. If documents are used further for any automations and OCR, use Document_Quality .

Image Quality values are:

enum ImageQuality {

Photo_Quality,

Document_Quality,

Compressed_Document

}

Parameters: ImageQuality | Return: void

  1. SetPageLayout (LayoutType ltype)

Set the Layout for the image default layouts are:

enum LayoutType {

A1,

A2,

A3,

A4,

A5,

A6,

A7,

PHOTO,

CUSTOM

}

Parameters: LayoutType | Return: void

  1. SetDPI (DPI dpi_value)

Set DPI (depth per inch) for the image.

Default DPI values are:

enum DPI {

DPI_100,

DPI_150,

DPI_200,

DPI_300,

DPI_500,

DPI_600

}

Parameters: DPI | Return: void

  1. SetCustomWidth (int value)

If image need to set custom width.

Parameters: width value in pixels as integer type | Return: void

  1. SetCustomHeight (int value)

If image need to set custom height.

Parameters: width value in pixels as integer type | Return: void

  1. SetMaxSize (long SizeinKB)

Set max size limit for the image. Size will be considered in KB (Kilo Bytes).

Parameters: max size of image in Kilobytes as type long & Return: void

  1. Bitmap GetThumbnail (Bitmap bm, int reqHeight, int reqWidth,Boolean AspectRatio)

Will build thumbnail for the given image in custom width,height and AspectRatio

Parameters: Bitmap image , int Height , int Width ,Boolean Aspect** _ **Ratio

Return: Thumbnail for the image as Bitmap Type.

  1. int GetThumbNailHeight ()

To get height of the thumbnail to generate

Parameters: N/A | Return: height in pixel as type integer.

  1. int GetThumbNailWidth ()

To get width of the thumbnail to generate

Parameters: N/A | Return: width in pixel as type integer.

  1. Bitmap LoadImage (String inputputURI, int reqHeight,int reqWidth)

Will load and build bitmap image from provided URL in requested width and height.

Parameters: String inputputURI , int reqHeight ,int reqWidth

Return: Build image in type Bitmap.

  1. Bitmap rotateBitmap (Bitmap bitmap, int orientation)

Rotate the image to preferred orientation

Parameters: Bitmap image, int orientation

Return: Rotated image as per given orientation in type Bitmap.

  1. Boolean CompressToJPEG (Bitmap bm, String outputURI)

Will Compress the provided bitmap image and will save to given path.

Parameters: Bitmap image , String outputURI

Return: Boolean True/false as per the operation is success or failure

  1. Bitmap CompressAndGetThumbnail (Bitmap bm, String outputURI,int RotationDegree)

Will compress, rotate and build thumbnail image in bitmap type and will save to given path. And will return the same build thumbnail.

Parameters: Bitmap image, String outputURI,int RotationDegree.

Return: build thumbnail as type bitmap.

  1. String getCurrentImageQuality ()

Will provide the current set compress quality.

Parameters: Nil.

Return: Current compression quality in string.

ImgException class

As a part of exceptional error handling ImgException class is available. Following are the possible errors and corresponding codes:

  • CREATE_FILE_ERROR = -100;
  • IMAGE_ROTATION_ERROR = -101;
  • LOAD_TO_BUFFER_ERROR = -102;
  • DELETE_FILE_ERROR = -103;
  • GET_ROTATION_ERROR = -104;
  • ROTATE_BITMAP_ERROR = -105;
  • BITMAP_RESIZE_ERROR = -106;
  • CAMERA_HELPER_ERROR = -107;
  • LOG_CREATION_ERROR = -108;

SDK Licensing

License file provided that should keep inside assets folder of main application and call UnlockImagingLibrary from ImgHelper class to unlock the SDK.

For UnlockImagingLibrary , need to pass main app activity context and the file.

Boolean UnlockImagingLibrary (Context activityContext , String licenseFile )

Will Unlock the Imaging library

Parameters: Context activityContext , String licenseFile

Return: true/false - unlock success / failed.

ImageHelper.UnlockImagingLibrary(this,"QuickCaptureSDKLicense.bin");

Once the license verification is success, then the water mark will disable from the images being generated by the SDK.

10 | Page

© 1996 - 2021 Extrieve Technologies