EyeQ Docs

Error Handling

Patterns for handling errors in the Perfectly Clear .NET API.

This page documents error handling patterns and status codes in the .NET API.

General pattern

The .NET API uses return codes rather than exceptions for most error conditions, allowing fine-grained control over error handling.

using (var pfc = new PerfectlyClear("license/path", ""))
{
    Bitmap bm = pfc.ReadImage("input.jpg");
    int result = pfc.AutoCorrect(ref bm);
    
    if (result < 0)
    {
        Console.WriteLine("Error: " + (PFCAPPLYSTATUS)result);
    }
    else if (result > 0)
    {
        HandleWarnings(result);
    }
    else
    {
        bm.Save("output.jpg");
    }
}

Decoding warnings

Positive return values contain encoded status information for each correction feature that can be extracted using bit operations.

void HandleWarnings(int code)
{
    PFCNR_STATUS nrStatus = (PFCNR_STATUS)(code & 0x000000FF);
    PFCCORE_STATUS coreStatus = (PFCCORE_STATUS)((code >> 8) & 0x000000FF);
    PFCFB_STATUS fbStatus = (PFCFB_STATUS)((code >> 16) & 0x000000FF);
    PFCRE_STATUS reStatus = (PFCRE_STATUS)((code >> 24) & 0x000000FF);
    
    if (fbStatus == PFCFB_STATUS.PFC_FB_WARNING)
        Console.WriteLine("No faces detected");
}

PFCAPPLYSTATUS

These status codes indicate the result of Apply and AutoCorrect operations.

ValueDescription
APPLY_SUCCESS with value 0Success
APPLY_ERROR_PROFILE_MISSING with value -1Profile is NULL
APPLY_ERROR_ENGINE_MISSING with value -2Engine is NULL
APPLY_CANCELLED with value -3Cancelled
APPLY_NOSOURCE with value -4Source image is NULL
APPLY_BADFORMAT with value -5Unsupported format
APPLY_INVALIDLICENSE with value -6Invalid license
APPLY_LOOKS_MISSING with value -12LUT file not found

License status codes

These codes are returned by SetProtectionPath to indicate license validation results.

CodeMeaning
0OK
102Success with active license
103Success with active trial
104License expired
113Trial expired

Using LastStatus

The LastStatus property provides detailed feature status information after Calc or Apply operations.

pfc.Calc(ref bm, PFCFEATURE.CALC_ALL);

if (pfc.LastStatus.FB_Status == PFCFB_STATUS.PFC_FB_WARNING)
{
    Console.WriteLine("No faces detected");
}

ADPTRRETURNCODE

These codes are returned by the Calc method to indicate analysis results.

ValueDescription
SUCCESSProcessed successfully
WARNINGSome warnings
INTERNALERRORInternal errors
WRONG_FORMATUnsupported format

PFC-SDK Version 10.7.2.1269 built from 4fa849d8101945eea725a08dd0dae5101f090fa0 on 11-10-2025.

Copyright © 2026 EyeQ Imaging Inc. All rights reserved.

On this page