Perfectly Clear SDK Documentation  9.1.1.325
Examples (Android)

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 ).

  1. Instantiate PerfectlyClear.V9 class instance:
  2. 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()) {
    //sets all params to those defined by a specific preset
    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.");
    }
    }
  3. Optionally one can set individual user parameters:
    // If needed, you can set individual parameters directly instead of loading a whole preset:
    param.core_bInfrared=true;
    param.core_fInfrared=1.00f;
  4. 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);
  5. 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);