Sample code Android Studio project are provided along with the SDK. The example below demonstrate the general usage of the Perfectly Clear SDK (class PerfectlyClear.V9 ).
- Instantiate PerfectlyClear.V9 class instance:
- Instantiate a PFCParam class instance and initialize with preset parameters. You may use class method SetParam() to initialize the PFCParam class instance with parameters from a preset directly from the SDK library.
Pfc.SetParam(param, Pfc.PRESET_IAUTO_21);
Alternately, you can import parameters from a preset file (.preset file). int retcode = Pfc.ReadPresetsFromStream(param, preset);
In summary: PFCParam param = new PFCParam();
if (presetFileString.isEmpty()) {
Pfc.SetParam(param, Pfc.PRESET_IAUTO_21);
} else {
try {
java.io.InputStream is = getApplicationContext().getAssets().open(presetFileString);
int size = is.available();
byte[] xml = new byte[size];
is.read(xml);
is.close();
String preset = new String(xml);
int retcode = Pfc.ReadPresetsFromStream(param, preset);
} catch (IOException ex) {
Log.v(LogTag, "Unable to read preset file.");
}
}
- Optionally one can set individual user parameters:
param.core_bInfrared=true;
param.core_fInfrared=1.00f;
- Perform full correction using the auto function:
int ret = Pfc.AutoCorrect(w, h, w * 4, V9.PFC_PixelFormat32bppABGR, bb, 0, 0, 0, null, param, 1);
- During allocation of direct buffer, we'd recommend using function AllocNativeBuffer() provided with the V9 class:
ByteBuffer bb = Pfc.allocNativeBuffer(w * h * 4);
and release the buffer using function DeallocNativeBuffer(). Pfc.freeNativeBuffer(bb);