Perfectly Clear SDK Documentation  8.3.1.149
PerfectlyClearAdapter.cs
Go to the documentation of this file.
1 
6 using System;
7 using System.Drawing;
8 using System.Drawing.Drawing2D;
9 using System.Diagnostics;
10 using System.Drawing.Imaging;
11 using System.IO;
12 using System.Runtime.InteropServices;
13 
15 {
17 public struct PFCPOINT
18 {
19  public int x;
20  public int y;
21 };
22 
24 public struct PFCRECT
25 {
26  public int left;
27  public int top;
28  public int width;
29  public int height;
30 };
31 
33 public struct PFCFBFACEINFO1
34 {
35  public PFCPOINT leftEye;
36  public PFCPOINT rightEye;
37  public PFCRECT face;
38 };
39 
41 public class PFCFBFACEINFO
42 {
43  public PFCPOINT leftEye;
44  public PFCPOINT rightEye;
45  public PFCRECT face;
46 
48  public PFCFBFACEINFO()
49  {
50  face.left = 0;
51  face.top = 0;
52  face.width = 0;
53  face.height = 0;
54  leftEye.x = 0;
55  leftEye.y = 0;
56  rightEye.x = 0;
57  rightEye.y = 0;
58  }
59 };
60 
62 public enum PFCFEATURE
63 {
64  CALC_CORE = 1,
65  CALC_NR = 2,
66  CALC_FB = 4,
67  CALC_RE = 8,
68  CALC_ALL = 15,
69  CALC_NOTINTCALC = 16,
70  CALC_NOFAE = 32,
71  CALC_FAEHISPEED = 64
72 };
73 
75 public enum PFCPIXELFORMAT
76 {
189 };
190 
192 public enum PFCPRESETID
193 {
197  PRESET_VIVID,
199 };
200 
202 public enum PFCNR_STATUS
203 {
212 };
213 
215 public enum PFCCORE_STATUS
216 {
224 };
225 
227 public enum PFCFB_STATUS
228 {
240 };
241 
243 public enum PFCRE_STATUS
244 {
254 };
255 
257 public enum PFCAPPLYSTATUS
258 {
259  APPLY_SUCCESS = 0,
262  APPLY_CANCELLED = -3,
263  APPLY_NOSOURCE = -4,
264  APPLY_BADFORMAT = -5,
266 };
267 
269 public enum TINTCORRECTION
270 {
275 };
276 
278 public enum AGGRESSIVENESS
279 {
280  CONSERVATIVE,
281  MODERATE,
282  AGGRESSIVE,
283 };
284 
286 public enum DCFMODE
287 {
290 };
291 
293 public enum CONTRASTMODE
294 {
295  HIGH_CONTRAST,
297 };
298 
300 public enum BIASMODE
301 {
302  BIAS_NONE,
306 };
307 
309 public enum ADPTRRETURNCODE
310 {
311  SUCCESS,
312  WARNING,
313  INTERNALERROR,
314  WRONG_FORMAT
315 };
316 
318 public enum SKINMODE
319 {
320  SKINMODE_FACE = 1,
322 };
323 
325 public enum SKINSMOOTHTYPE
326 {
330 };
331 
333 public enum SKINTONINGTYPE
334 {
340 };
341 
343 public enum LIPSHARPENTYPE
344 {
345  LIPSHARPENTYPE_FINE = 1,
348 };
349 
351 public struct PFCCOREPARAM
352 {
353  public bool bEnabled;
354  public bool bAbnormalTintRemoval;
356  public float fTintScale;
357  public int iBlackEnhancement;
358  public bool bVibrancy;
359  public int iVibrancy;
360  public int iStrength;
361  public bool bContrast;
363  public int iContrast;
365  public float fBiasScale;
366  public bool bSharpen;
367  public float fSharpenScale;
369  public bool bUseFAE;
371  public int iMaxStrength;
372  public bool bInfrared;
373  public float fInfrared;
374  public bool bLightDiffusion;
375  public float fLightDiffusion;
376  public bool bDynamicRange;
377  public bool bDCF;
378  public DCFMODE eDCFMode;
379  public float fDCF;
380 };
381 
383 public struct PFCFBPARAM
384 {
385  public bool bEnabled;
386  public bool bSmooth;
387  public int iSmoothLevel;
390  public bool bEnlarge;
391  public int iEnlargeLevel;
392  public bool bEnhance;
393  public int iEnhanceLevel;
394  public bool bEyeCirc;
395  public int iEyeCirc;
396  public bool bTeeth;
397  public int iTeethLevel;
398  public bool bBlemish;
399  public int iBlemish;
400  public bool bSlim;
401  public int iSlim;
402  public bool bDeFlash;
403  public int iDeFlash;
404  public bool bCatchLight;
405  public int iCatchLight;
406  public int iCatchLightMode;
407  public bool bSkinToning;
414  public int iSkinToning;
417  public bool bLipSharpen;
418  public int iLipSharpen;
420  public bool bBlush;
421  public int iBlush;
422 };
423 
425 public unsafe struct PFCNRPARAM
426 {
427  public bool bEnabled;
428  public int iPreset;
429  public int iStrengthOffset;
437  public int iDetailOffset;
438 };
439 
441 public struct PFCREPARAM
442 
443 {
444  public bool bEnabled;
445 };
446 
447 // V3 additions
448 public enum PFCCORE_MASK_TYPE
449 {
450  PFCCORE_MASK_NONE, // 0.0 everywhere, don't apply
451  PFCCORE_MASK_ALL, // 1.0 everywhere (background)
452  PFCCORE_MASK_RADIAL, // ellipse
453  PFCCORE_MASK_TOP, // linear from 1.0 on top
454  PFCCORE_MASK_BOTTOM, // linear from 1.0 on bottom
455  PFCCORE_MASK_ROUNDRECT // rounded rect
456 };
457 
458 /* Description of mask for grad filter, all coordinates are relative (Y/height, X/width) in final crop-rotated image */
462 public unsafe struct PFCCOREMask
463 {
464  public PFCCORE_MASK_TYPE type;
465  public float centerX;
466  public float centerY;
467  public float width;
468  public float height;
469  public float radius;
470  public float feather;
471  public float angle;
472  public float transparency;
473  public bool invert;
474 };
475 
476 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
478 public struct PFC3DLutInfo
479 {
480  [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 33)]
481  public string guid;
482 
483  public byte strength; // C++ unsigned char
484 }
485 
487 public unsafe struct PFCV3PARAM
488 {
489  // Image Ambulance
490  public bool bPreprocessEV;
491  public int iPreprocessEV;
492  // built-in 3D luts
493  public int iNeutralDensity;
494  public int iColorVibrancy;
499  // custom output 3D Lut
501  // Finishing
502  public int iFinishTemp;
503  public int iFinishTint;
504  public int iFinishExposure;
505  public int iFinishBlacks;
506  public int iFinishShadows;
507  public int iFinishHighlights;
508  public int iFinishWhites;
509  public int iFinishSaturation;
510  public int iFinishVibrancy;
511  public int iFinishContrast;
512 };
513 
514 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
516 public struct PFCPARAM
517 {
519  public PFCFBPARAM fb;
520  public PFCNRPARAM nr;
521  public PFCREPARAM re;
522  public PFCV3PARAM v3;
529 };
530 
532 public struct PFCSTATUS
533 {
534  public PFCCORE_STATUS CORE_Status;
535  public PFCNR_STATUS NR_Status;
536  public PFCFB_STATUS FB_Status;
537  public PFCRE_STATUS RE_Status;
538  public int Status;
539 }
540 
547  public unsafe class PerfectlyClear : IDisposable
548  {
550  protected unsafe struct PFCENGINE
551  {
552  void* pEngine;
553  public uint status;
554  };
556  protected unsafe struct PerfectlyClearImageTransfer
557  {
558  public int width;
559  public int height;
560  public int rowBytes;
561  public int columnBytes;
562  public int data1;
563  public int data2;
564  public int data3;
565  };
566 
568  protected unsafe struct PFCIMAGEPROFILE
569  {
570  void* pPfcParam;
571  void* pNoiseParam;
572  void* pRedEyeParam;
573  void* pSFBParam;
574  void* pInternal;
575 
580 
581  public int Status;
582  };
589 
591  protected unsafe struct PFCIMAGE
592  {
593  public int width;
594  public int height;
595  public int stride;
597  public void* data;
598  };
599 
600 
601  protected PFCENGINE* m_pEngine;
602  protected PFCIMAGEPROFILE* m_pProfile;
603  public PFCPARAM m_Param;
604  public PFCSTATUS LastStatus;
605 
611  public PerfectlyClear(string path = "")
612  {
613  m_pEngine = null;
614  m_pProfile = null;
615 
616 #if PROTECTION_ENABLED
617  try
618  {
619  byte* pLicpath = null;
620  if (path != null)
621  {
622  pLicpath = GetCharBuffer(path);
623  }
624 
625  int status = PFC_SetProtectionPath(pLicpath);
626  //Trace.WriteLine("status " + status.ToString());
627  }
628  catch (Exception ex)
629  {
630  Trace.WriteLine(ex.Message);
631  }
632 #endif
633  try
634  {
635  m_pEngine = PFC_CreateEngine();
636  if (m_pEngine != null)
637  {
638  LastStatus.Status = (int)(*m_pEngine).status;
639  }
640  }
641  catch (Exception ex)
642  {
643  Trace.WriteLine(ex.Message);
644  }
645 
646  PFC_SetParam(ref m_Param, PFCPRESETID.PRESET_INTELLIGENTAUTO);
647  }
648 
649  ~PerfectlyClear()
650  {
651 #if PROTECTION_ENABLED
652  PFC_ReleaseProtectionPath();
653 #endif
654  Dispose(false);
655  }
656 
661  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm)
662  {
663  return Calc(ref bm, PFCFEATURE.CALC_ALL, -1, null);
664  }
665 
671  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds)
672  {
673  return Calc(ref bm, ref bmds, PFCFEATURE.CALC_ALL, -1, null);
674  }
675 
681  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature)
682  {
683  return Calc(ref bm, feature, -1, null);
684  }
685 
692  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature)
693  {
694  return Calc(ref bm, ref bmds, feature, -1, null);
695  }
696 
704  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature, int ISO, string CameraModel)
705  {
706  BitmapData bd = null;
707  Byte* pBase = null;
708  bd = LockBitmapData(ref bm);
709  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
710  bd.PixelFormat != PixelFormat.Format32bppArgb &&
711  bd.PixelFormat != PixelFormat.Format48bppRgb &&
712  bd.PixelFormat != PixelFormat.Format64bppArgb)
713  {
714  ReleaseBitmapData(ref bm, ref bd);
715  return ADPTRRETURNCODE.WRONG_FORMAT;
716  }
717  pBase = (Byte*)bd.Scan0.ToPointer();
718 
719  PFCIMAGE im;
720  im.width = bd.Width;
721  im.height = bd.Height;
722  im.stride = bd.Stride;
723  switch (bd.PixelFormat)
724  {
725  default:
726  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
727  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
728  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
729  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
730  }
731  im.data = (void*)pBase;
732 
733  if (m_pProfile != null)
734  PFC_ReleaseProfile(m_pProfile);
735 
736  byte* pModel = null;
737  if (CameraModel != null)
738  {
739  pModel = GetCharBuffer(CameraModel);
740  }
741  m_pProfile = PFC_Calc(&im, null, m_pEngine, feature, ISO, pModel, null, null, 1);
742 
743  FreeCharBuffer(pModel);
744 
745  ReleaseBitmapData(ref bm, ref bd);
746 
747  LastStatus.NR_Status = (*m_pProfile).NR_Status;
748  LastStatus.CORE_Status = (*m_pProfile).CORE_Status;
749  LastStatus.FB_Status = (*m_pProfile).FB_Status;
750  LastStatus.RE_Status = (*m_pProfile).RE_Status;
751  LastStatus.Status = (*m_pProfile).Status;
752 
753  return (LastStatus.Status == 0) ? ADPTRRETURNCODE.SUCCESS : ADPTRRETURNCODE.WARNING;
754  }
755 
764  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature, int ISO, string CameraModel)
765  {
766  BitmapData bd = null;
767  Byte* pBase = null;
768  bd = LockBitmapData(ref bm);
769  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
770  bd.PixelFormat != PixelFormat.Format32bppArgb &&
771  bd.PixelFormat != PixelFormat.Format48bppRgb &&
772  bd.PixelFormat != PixelFormat.Format64bppArgb)
773  {
774  ReleaseBitmapData(ref bm, ref bd);
775  return ADPTRRETURNCODE.WRONG_FORMAT;
776  }
777  pBase = (Byte*)bd.Scan0.ToPointer();
778 
779  PFCIMAGE im;
780  im.width = bd.Width;
781  im.height = bd.Height;
782  im.stride = bd.Stride;
783  switch (bd.PixelFormat)
784  {
785  default:
786  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
787  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
788  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
789  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
790  }
791  im.data = (void*)pBase;
792 
793  BitmapData bdds = null;
794  bdds = LockBitmapData(ref bmds);
795  if (bdds.PixelFormat != PixelFormat.Format24bppRgb &&
796  bdds.PixelFormat != PixelFormat.Format32bppArgb &&
797  bdds.PixelFormat != PixelFormat.Format48bppRgb &&
798  bdds.PixelFormat != PixelFormat.Format64bppArgb)
799  {
800  ReleaseBitmapData(ref bmds, ref bdds);
801  return ADPTRRETURNCODE.WRONG_FORMAT;
802  }
803  pBase = (Byte*)bdds.Scan0.ToPointer();
804 
805  PFCIMAGE imds;
806  imds.width = bdds.Width;
807  imds.height = bdds.Height;
808  imds.stride = bdds.Stride;
809  switch (bdds.PixelFormat)
810  {
811  default:
812  case PixelFormat.Format24bppRgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
813  case PixelFormat.Format32bppArgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
814  case PixelFormat.Format48bppRgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
815  case PixelFormat.Format64bppArgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
816  }
817  imds.data = (void*)pBase;
818 
819  if (m_pProfile != null)
820  PFC_ReleaseProfile(m_pProfile);
821 
822  byte* pModel = null;
823  if (CameraModel != null)
824  {
825  pModel = GetCharBuffer(CameraModel);
826  }
827  m_pProfile = PFC_Calc(&im, &imds, m_pEngine, feature, ISO, pModel, null, null, 1);
828 
829  FreeCharBuffer(pModel);
830 
831  ReleaseBitmapData(ref bm, ref bd);
832  ReleaseBitmapData(ref bmds, ref bdds);
833 
834  LastStatus.NR_Status = (*m_pProfile).NR_Status;
835  LastStatus.CORE_Status = (*m_pProfile).CORE_Status;
836  LastStatus.FB_Status = (*m_pProfile).FB_Status;
837  LastStatus.RE_Status = (*m_pProfile).RE_Status;
838  LastStatus.Status = (*m_pProfile).Status;
839 
840  return (LastStatus.Status == 0) ? ADPTRRETURNCODE.SUCCESS : ADPTRRETURNCODE.WARNING;
841  }
842 
847  public unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm)
848  {
849  return Apply(ref bm, 100);
850  }
851 
857  public unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm, int iOpacity)
858  {
859  if (m_pProfile == null)
860  {
861  return PFCAPPLYSTATUS.APPLY_ERROR_PROFILE_MISSING;
862  }
863 
864  BitmapData bd = null;
865  Byte* pBase = null;
866  bd = LockBitmapData(ref bm);
867  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
868  bd.PixelFormat != PixelFormat.Format32bppArgb &&
869  bd.PixelFormat != PixelFormat.Format48bppRgb &&
870  bd.PixelFormat != PixelFormat.Format64bppArgb)
871  {
872  ReleaseBitmapData(ref bm, ref bd);
873  return PFCAPPLYSTATUS.APPLY_BADFORMAT;
874  }
875  pBase = (Byte*)bd.Scan0.ToPointer();
876 
877  PFCIMAGE im;
878  im.width = bd.Width;
879  im.height = bd.Height;
880  im.stride = bd.Stride;
881  switch (bd.PixelFormat)
882  {
883  default:
884  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
885  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
886  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
887  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
888  }
889  im.data = (void*)pBase;
890 
891  PFCAPPLYSTATUS ret = PFC_Apply(&im, m_pEngine, m_pProfile, ref m_Param, null, iOpacity);
892 
893  if (ret > 0)
894  {
895  int code = (int)ret;
896  // Get individual return codes
897  LastStatus.NR_Status = (PFCNR_STATUS)(code & 0x000000FF);
898  LastStatus.CORE_Status = (PFCCORE_STATUS)((code >> 8) & 0x000000FF);
899  LastStatus.FB_Status = (PFCFB_STATUS)((code >> 16) & 0x000000FF);
900  LastStatus.RE_Status = (PFCRE_STATUS)((code >> 24) & 0x000000FF);
901  LastStatus.Status = code;
902  }
903 
904  ReleaseBitmapData(ref bm, ref bd);
905  return ret;
906  }
907 
908  public unsafe PFCAPPLYSTATUS ApplyLocal(ref Bitmap bm, int xOffset, int yOffset, int widthOrig, int heightOrig)
909  {
910  return ApplyLocal(ref bm, xOffset, yOffset, widthOrig, heightOrig, 100);
911  }
912 
913  public unsafe PFCAPPLYSTATUS ApplyLocal(ref Bitmap bm, int xOffset, int yOffset, int widthOrig, int heightOrig, int iOpacity)
914  {
915  BitmapData bd = null;
916  Byte* pBase = null;
917  bd = LockBitmapData(ref bm);
918  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
919  bd.PixelFormat != PixelFormat.Format32bppArgb &&
920  bd.PixelFormat != PixelFormat.Format48bppRgb &&
921  bd.PixelFormat != PixelFormat.Format64bppArgb)
922  {
923  ReleaseBitmapData(ref bm, ref bd);
924  return PFCAPPLYSTATUS.APPLY_BADFORMAT;
925  }
926  pBase = (Byte*)bd.Scan0.ToPointer();
927 
928  PFCIMAGE im;
929  im.width = bd.Width;
930  im.height = bd.Height;
931  im.stride = bd.Stride;
932  switch (bd.PixelFormat)
933  {
934  default:
935  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
936  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
937  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
938  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
939  }
940  im.data = (void*)pBase;
941 
942  PFCAPPLYSTATUS ret = PFC_ApplyLocal(&im, xOffset, yOffset, widthOrig, heightOrig, m_pEngine, m_pProfile, ref m_Param, iOpacity);
943 
944  ReleaseBitmapData(ref bm, ref bd);
945  return ret;
946  }
947 
967  public int AutoCorrect(ref Bitmap bm)
968  {
969  return AutoCorrect(ref bm, -1, null, false);
970  }
971 
991  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds)
992  {
993  return AutoCorrect(ref bm, ref bmds, -1, null, false);
994  }
995 
1017  public int AutoCorrect(ref Bitmap bm, int ISO, string CameraModel, bool bFastFAE)
1018  {
1019  PFCFEATURE feature = 0;
1020  if (m_Param.nr.bEnabled)
1021  feature |= PFCFEATURE.CALC_NR;
1022  if (m_Param.core.bEnabled)
1023  feature |= PFCFEATURE.CALC_CORE;
1024  if (m_Param.fb.bEnabled)
1025  feature |= PFCFEATURE.CALC_FB;
1026  if (m_Param.re.bEnabled)
1027  feature |= PFCFEATURE.CALC_RE;
1028  if (!m_Param.core.bAbnormalTintRemoval)
1029  feature |= PFCFEATURE.CALC_NOTINTCALC;
1030  // Any FAE optimization
1031  if (m_Param.core.bUseFAE)
1032  {
1033  if (bFastFAE)
1034  feature |= PFCFEATURE.CALC_FAEHISPEED;
1035  }
1036  else
1037  {
1038  feature |= PFCFEATURE.CALC_NOFAE;
1039  }
1040 
1041  ADPTRRETURNCODE ret = Calc(ref bm, feature, ISO, CameraModel);
1042  // Process image regardless of return code
1043  PFCAPPLYSTATUS aret = Apply(ref bm);
1044 
1045  if (ret != ADPTRRETURNCODE.SUCCESS && ret != ADPTRRETURNCODE.WARNING)
1046  {
1047  PFCNR_STATUS retNR = LastStatus.NR_Status;
1048  if (retNR == PFCNR_STATUS.PFC_NR_NOTFOUND || retNR == PFCNR_STATUS.PFC_NR_NOTENABLED)
1049  retNR = PFCNR_STATUS.PFC_NR_SUCCESS;
1050 
1051  PFCCORE_STATUS retCORE = LastStatus.CORE_Status;
1052  if (retCORE == PFCCORE_STATUS.PFC_CORE_NOTENABLED)
1053  retCORE = PFCCORE_STATUS.PFC_CORE_SUCCESS;
1054 
1055  PFCFB_STATUS retFB = LastStatus.FB_Status;
1056  if (retFB == PFCFB_STATUS.PFC_FB_NOTENABLED || retFB == PFCFB_STATUS.PFC_FB_WARNING)
1057  retFB = PFCFB_STATUS.PFC_FB_SUCCESS;
1058 
1059  PFCRE_STATUS retRE = LastStatus.RE_Status;
1060  if (retRE == PFCRE_STATUS.PFC_RE_NOTENABLED || retRE == PFCRE_STATUS.PFC_RE_NOT_FOUND)
1061  retRE = PFCRE_STATUS.PFC_RE_SUCCESS;
1062 
1063  int retInt = (((((((int)retRE << 8) | (int)retFB) << 8) | (int)retCORE) << 8) | (int)retNR);
1064  return retInt;
1065  }
1066  else
1067  {
1068  return (int)aret;
1069  }
1070  }
1071 
1095  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, int ISO, string CameraModel, bool bFastFAE)
1096  {
1097  PFCFEATURE feature = 0;
1098  if (m_Param.nr.bEnabled)
1099  feature |= PFCFEATURE.CALC_NR;
1100  if (m_Param.core.bEnabled)
1101  feature |= PFCFEATURE.CALC_CORE;
1102  if (m_Param.fb.bEnabled)
1103  feature |= PFCFEATURE.CALC_FB;
1104  if (m_Param.re.bEnabled)
1105  feature |= PFCFEATURE.CALC_RE;
1106  if (!m_Param.core.bAbnormalTintRemoval)
1107  feature |= PFCFEATURE.CALC_NOTINTCALC;
1108  // Any FAE optimization
1109  if (m_Param.core.bUseFAE)
1110  {
1111  if (bFastFAE)
1112  feature |= PFCFEATURE.CALC_FAEHISPEED;
1113  }
1114  else
1115  {
1116  feature |= PFCFEATURE.CALC_NOFAE;
1117  }
1118 
1119  ADPTRRETURNCODE ret = Calc(ref bm, ref bmds, feature, ISO, CameraModel);
1120  // Process image regardless of return code
1121  PFCAPPLYSTATUS aret = Apply(ref bm);
1122 
1123  if (ret != ADPTRRETURNCODE.SUCCESS && ret != ADPTRRETURNCODE.WARNING)
1124  {
1125  PFCNR_STATUS retNR = LastStatus.NR_Status;
1126  if (retNR == PFCNR_STATUS.PFC_NR_NOTFOUND || retNR == PFCNR_STATUS.PFC_NR_NOTENABLED)
1127  retNR = PFCNR_STATUS.PFC_NR_SUCCESS;
1128 
1129  PFCCORE_STATUS retCORE = LastStatus.CORE_Status;
1130  if (retCORE == PFCCORE_STATUS.PFC_CORE_NOTENABLED)
1131  retCORE = PFCCORE_STATUS.PFC_CORE_SUCCESS;
1132 
1133  PFCFB_STATUS retFB = LastStatus.FB_Status;
1134  if (retFB == PFCFB_STATUS.PFC_FB_NOTENABLED || retFB == PFCFB_STATUS.PFC_FB_WARNING)
1135  retFB = PFCFB_STATUS.PFC_FB_SUCCESS;
1136 
1137  PFCRE_STATUS retRE = LastStatus.RE_Status;
1138  if (retRE == PFCRE_STATUS.PFC_RE_NOTENABLED || retRE == PFCRE_STATUS.PFC_RE_NOT_FOUND)
1139  retRE = PFCRE_STATUS.PFC_RE_SUCCESS;
1140 
1141  int retInt = (((((((int)retRE << 8) | (int)retFB) << 8) | (int)retCORE) << 8) | (int)retNR);
1142  return retInt;
1143  }
1144  else
1145  {
1146  return (int)aret;
1147  }
1148  }
1149 
1182  public int AutoCorrect(ref Bitmap bm, string pathPreset)
1183  {
1184  int retCode = ReadPresets(pathPreset);
1185  if (retCode == 0)
1186  {
1187  return AutoCorrect(ref bm, -1, null, false);
1188  }
1189  return retCode-1000;
1190  }
1191 
1224  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset)
1225  {
1226  int retCode = ReadPresets(pathPreset);
1227  if (retCode == 0)
1228  {
1229  return AutoCorrect(ref bm, ref bmds, -1, null, false);
1230  }
1231  return retCode - 1000;
1232  }
1233 
1268  public int AutoCorrect(ref Bitmap bm, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
1269  {
1270  int retCode = ReadPresets(pathPreset);
1271  if (retCode == 0)
1272  {
1273  return AutoCorrect(ref bm, ISO, CameraModel, bFastFAE);
1274  }
1275  return retCode - 1000;
1276  }
1277 
1313  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
1314  {
1315  int retCode = ReadPresets(pathPreset);
1316  if (retCode == 0)
1317  {
1318  return AutoCorrect(ref bm, ref bmds, ISO, CameraModel, bFastFAE);
1319  }
1320  return retCode - 1000;
1321  }
1322 
1327  public void SetParam(PFCPRESETID id)
1328  {
1329  PFC_SetParam(ref m_Param, id);
1330  }
1331 
1348  public int ReadPresets(string path)
1349  {
1350  try
1351  {
1352  byte* presetpath = null;
1353  if (path != null)
1354  {
1355  presetpath = GetCharBuffer(path);
1356  }
1357 
1358  // PFC_ReadPresets return code
1359  // 0 - Success
1360  // -1 - Attribute errors
1361  // -2 - Unable to open file
1362  // -3 - File read error.
1363  // -4 - Parse error.
1364  // -5 - Cannot convert text.
1365  // -6 - No text node.
1366  // -7 - Element depth exceeded.
1367  int status = PFC_ReadPresets(ref m_Param, presetpath);
1368  //Trace.WriteLine("status " + status.ToString());
1369  return status;
1370  }
1371  catch (Exception ex)
1372  {
1373  Trace.WriteLine(ex.Message);
1374  }
1375  return -8;
1376  }
1377 
1389  public int ReadPresetsFromStream(FileStream fs)
1390  {
1391  try
1392  {
1393  long len = fs.Length;
1394  byte[] buffer = new byte[len + 1];
1395  int size = (int)len;
1396  fs.Read(buffer, 0, size);
1397  buffer[size] = 0;
1398  byte* b = GetCharBuffer(buffer);
1399  // PFC_ReadPresetsFromStream return codes
1400  // 0 - success
1401  // -3 - Stream read error.
1402  // -4 - Parse error.
1403  int status = PFC_ReadPresetsFromStream(ref m_Param, b);
1404  FreeCharBuffer(b);
1405  return status;
1406  }
1407  catch (Exception ex)
1408  {
1409  Trace.WriteLine(ex.Message);
1410  }
1411  return -8;
1412  }
1413 
1419  {
1420  return PFC_HasFaceBeautification(m_pEngine);
1421  }
1422 
1427  public int FBFaceCount()
1428  {
1429  return PFC_FBFaceCount(m_pProfile);
1430  }
1431 
1439  public bool GetFaceInfo(ref PFCFBFACEINFO info, int index)
1440  {
1441  PFCFBFACEINFO1 fi;
1442  bool ret = PFC_GetFaceInfo(m_pProfile, &fi, index);
1443  info.face.left = fi.face.left;
1444  info.face.top = fi.face.top;
1445  info.face.width = fi.face.width;
1446  info.face.height = fi.face.height;
1447  info.leftEye.x = fi.leftEye.x;
1448  info.leftEye.y = fi.leftEye.y;
1449  info.rightEye.x = fi.rightEye.x;
1450  info.rightEye.y = fi.rightEye.y;
1451  return ret;
1452  }
1453 
1458  public bool AbnormalTintDetected(TINTCORRECTION eTintMethod)
1459  {
1460  return PFC_AbnormalTintDetected(m_pProfile, eTintMethod);
1461  }
1462 
1463  protected BitmapData LockBitmapData(ref Bitmap bm)
1464  {
1465  GraphicsUnit unit = GraphicsUnit.Pixel;
1466  RectangleF boundsF = bm.GetBounds(ref unit);
1467  Rectangle bounds = new Rectangle((int)boundsF.X,
1468  (int)boundsF.Y,
1469  (int)boundsF.Width,
1470  (int)boundsF.Height);
1471 
1472  BitmapData bitmapData =
1473  bm.LockBits(bounds, ImageLockMode.ReadWrite, bm.PixelFormat);
1474  return bitmapData;
1475  }
1476 
1477  protected void ReleaseBitmapData(ref Bitmap bm, ref BitmapData bitmapData)
1478  {
1479  bm.UnlockBits(bitmapData);
1480  }
1481 
1482  protected Bitmap DupBitmap(ref Bitmap bm)
1483  {
1484  PerfectlyClearImageTransfer tr, tr1;
1485  Byte* pBase = null;
1486  GraphicsUnit unit = GraphicsUnit.Pixel;
1487  RectangleF boundsF = bm.GetBounds(ref unit);
1488  Rectangle bounds = new Rectangle((int)boundsF.X,
1489  (int)boundsF.Y,
1490  (int)boundsF.Width,
1491  (int)boundsF.Height);
1492  BitmapData bd = bm.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
1493  Bitmap bm1 = new Bitmap(bd.Width, bd.Height, PixelFormat.Format24bppRgb);
1494  BitmapData bd1 = LockBitmapData(ref bm1);
1495  pBase = (Byte*)bd.Scan0.ToPointer();
1496  tr.columnBytes = (bd.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
1497  tr.rowBytes = bd.Stride;
1498  tr.height = bd.Height;
1499  tr.width = bd.Width;
1500  tr.data1 = (int)(pBase + 2);
1501  tr.data2 = (int)(pBase + 1);
1502  tr.data3 = (int)pBase;
1503  pBase = (Byte*)bd1.Scan0.ToPointer();
1504  tr1.columnBytes = (bd1.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
1505  tr1.rowBytes = bd1.Stride;
1506  tr1.height = bd1.Height;
1507  tr1.width = bd1.Width;
1508  tr1.data1 = (int)(pBase + 2);
1509  tr1.data2 = (int)(pBase + 1);
1510  tr1.data3 = (int)pBase;
1511  for (int i = 0; i < tr.height; i++)
1512  {
1513  for (int j = 0; j < tr.width; j++)
1514  {
1515  ((Byte*)tr1.data1)[j * tr1.columnBytes] = ((Byte*)tr.data1)[j * tr.columnBytes];
1516  ((Byte*)tr1.data2)[j * tr1.columnBytes] = ((Byte*)tr.data2)[j * tr.columnBytes];
1517  ((Byte*)tr1.data3)[j * tr1.columnBytes] = ((Byte*)tr.data3)[j * tr.columnBytes];
1518  }
1519  tr.data1 += (int)tr.rowBytes;
1520  tr.data2 += (int)tr.rowBytes;
1521  tr.data3 += (int)tr.rowBytes;
1522  tr1.data1 += (int)tr1.rowBytes;
1523  tr1.data2 += (int)tr1.rowBytes;
1524  tr1.data3 += (int)tr1.rowBytes;
1525  }
1526  ReleaseBitmapData(ref bm1, ref bd1);
1527  ReleaseBitmapData(ref bm, ref bd);
1528  return bm1;
1529  }
1530 
1531  protected Bitmap BW2RGB(ref Bitmap bm)
1532  {
1533  Byte* pBase = null;
1534  Byte* pBase1 = null;
1535  GraphicsUnit unit = GraphicsUnit.Pixel;
1536  RectangleF boundsF = bm.GetBounds(ref unit);
1537  Rectangle bounds = new Rectangle((int)boundsF.X,
1538  (int)boundsF.Y,
1539  (int)boundsF.Width,
1540  (int)boundsF.Height);
1541  BitmapData bd = bm.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
1542  Bitmap bm1 = new Bitmap(bd.Width, bd.Height, PixelFormat.Format24bppRgb);
1543  BitmapData bd1 = LockBitmapData(ref bm1);
1544  pBase = (Byte*)bd.Scan0.ToPointer();
1545  pBase1 = (Byte*)bd1.Scan0.ToPointer();
1546  for (int i = 0; i < bd.Height; i++)
1547  {
1548  for (int j = 0; j < bd.Width; j++)
1549  {
1550  pBase1[j * 3] = pBase[j];
1551  pBase1[j * 3 + 1] = pBase[j];
1552  pBase1[j * 3 + 2] = pBase[j];
1553  }
1554  pBase += bd.Stride;
1555  pBase1 += bd1.Stride;
1556  }
1557  ReleaseBitmapData(ref bm1, ref bd1);
1558  ReleaseBitmapData(ref bm, ref bd);
1559  return bm1;
1560  }
1561 
1568  public Bitmap ReadImage(string filename)
1569  {
1570  Bitmap bm = null;
1571  Bitmap myBitmap = new Bitmap(filename);
1572  if ((myBitmap.Flags & (int)ImageFlags.ColorSpaceYcck) != 0)
1573  {
1574  bm = DupBitmap(ref myBitmap);
1575  myBitmap.Dispose();
1576  }
1577  else
1578  {
1579  if (myBitmap.PixelFormat == PixelFormat.Format8bppIndexed)
1580  {
1581  bm = BW2RGB(ref myBitmap);
1582  myBitmap.Dispose();
1583  }
1584  else
1585  {
1586  bm = myBitmap;
1587  }
1588  }
1589  return bm;
1590  }
1591 
1592  protected Bitmap GetStatImage(ref Bitmap bm, int iMaxDimension)
1593  {
1594  // Build max dim reference image
1595  bool bNeedResize = true;
1596  int w, h, w1, h1;
1597  w = bm.Width;
1598  h = bm.Height;
1599  // Calculate size of reference image. One dimension is 1024.
1600  if (w > h)
1601  {
1602  if (w <= iMaxDimension)
1603  bNeedResize = false;
1604  w1 = iMaxDimension;
1605  h1 = w1 * h / w;
1606  }
1607  else
1608  {
1609  if (h <= iMaxDimension)
1610  bNeedResize = false;
1611  h1 = iMaxDimension;
1612  w1 = h1 * w / h;
1613  }
1614 
1615  if (bNeedResize)
1616  {
1617  //
1618  // Step 2.
1619  // Create temporary bitmap to assist red eye analysis.
1620  //
1621  Bitmap bmds = new Bitmap(w1, h1, bm.PixelFormat);
1622  {
1623  using (Graphics gr = Graphics.FromImage(bmds))
1624  {
1625  gr.SmoothingMode = SmoothingMode.HighQuality;
1626  gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
1627  gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
1628  gr.DrawImage(bm, new Rectangle(0, 0, w1, h1));
1629  }
1630  }
1631 
1632  return bmds;
1633  }
1634  else
1635  {
1636  Bitmap bmds = (Bitmap)bm.Clone();
1637  return bmds;
1638  }
1639  }
1640 
1641  public void Dispose()
1642  {
1643  Dispose(true);
1644  GC.SuppressFinalize(this);
1645  }
1646 
1647  protected virtual void Dispose(bool disposing)
1648  {
1649  if (disposing)
1650  {
1651  }
1652 
1653  if (m_pProfile != null)
1654  {
1655  PFC_ReleaseProfile(m_pProfile);
1656  m_pProfile = null;
1657  }
1658 
1659  if (m_pEngine != null)
1660  {
1661  PFC_DestroyEngine(m_pEngine);
1662  m_pEngine = null;
1663  }
1664  }
1665 
1666  protected byte* GetCharBuffer(byte[] s)
1667  {
1668  int i, iCount = s.Length;
1669  IntPtr _memory = IntPtr.Zero;
1670  _memory = Marshal.AllocHGlobal(iCount + 1);
1671  byte* p = (byte*)_memory;
1672  for (i = 0; i < iCount; i++)
1673  {
1674  p[i] = (byte)s[i];
1675  }
1676  p[iCount] = 0;
1677 
1678  return (byte*)p;
1679  }
1680 
1681  protected byte* GetCharBuffer(string s)
1682  {
1683  int i, iCount = s.Length;
1684  IntPtr _memory = IntPtr.Zero;
1685  _memory = Marshal.AllocHGlobal(iCount + 1);
1686  byte* p = (byte*)_memory;
1687  for (i = 0; i < iCount; i++)
1688  {
1689  p[i] = (byte)s[i];
1690  }
1691  p[iCount] = 0;
1692 
1693  return (byte*)p;
1694  }
1695 
1696  protected void FreeCharBuffer(byte* p)
1697  {
1698  IntPtr _memory = (IntPtr)p;
1699  Marshal.FreeHGlobal(_memory);
1700  }
1701 
1702 #if ADAPTER64BIT
1703  [DllImport("PerfectlyClearPro.dll")]
1704  static extern int PFC_SetProtectionPath(byte* path);
1705 
1706  [DllImport("PerfectlyClearPro.dll")]
1707  static extern void PFC_ReleaseProtectionPath();
1708 
1709  [DllImport("PerfectlyClearPro.dll")]
1710  static extern PFCENGINE* PFC_CreateEngine();
1711 
1712  [DllImport("PerfectlyClearPro.dll")]
1713  static extern void PFC_DestroyEngine(PFCENGINE* p);
1714 
1715  [DllImport("PerfectlyClearPro.dll")]
1716  static extern void PFC_SetParam(ref PFCPARAM param, PFCPRESETID id);
1717 
1718  [DllImport("PerfectlyClearPro.dll")]
1719  static extern int PFC_ReadPresets(ref PFCPARAM param, byte* filename);
1720 
1721  [DllImport("PerfectlyClearPro.dll")]
1722  static extern int PFC_ReadPresetsFromStream(ref PFCPARAM param, byte* s);
1723 
1724  [DllImport("PerfectlyClearPro.dll")]
1725  static extern PFCIMAGEPROFILE* PFC_Calc(PFCIMAGE* pImage, PFCIMAGE* pImageds, PFCENGINE* pEngine, PFCFEATURE feature, int iISO, byte* pCameraModel, void* pImageProfile, void* progfn, int bRejectMonolith);
1726 
1727  [DllImport("PerfectlyClearPro.dll")]
1728  static extern void PFC_ReleaseProfile(void* pProfile);
1729 
1730  [DllImport("PerfectlyClearPro.dll")]
1731  static extern PFCAPPLYSTATUS PFC_Apply(PFCIMAGE* pImage, PFCENGINE* pEngine, void* pImageProfile, ref PFCPARAM param, void* progfn, int iOpacity);
1732 
1733  [DllImport("PerfectlyClearPro.dll")]
1734  static extern PFCAPPLYSTATUS PFC_ApplyLocal(PFCIMAGE* pImage, int xOffset, int yOffset, int widthOrig, int heightOrig, PFCENGINE* pEngine, PFCIMAGEPROFILE* pImageProfile, ref PFCPARAM param, int iOpacity);
1735 
1736  [DllImport("PerfectlyClearPro.dll")]
1737  static extern bool PFC_HasFaceBeautification(PFCENGINE* pEngine);
1738 
1739  [DllImport("PerfectlyClearPro.dll")]
1740  static extern int PFC_FBFaceCount(void* pImageProfile);
1741 
1742  [DllImport("PerfectlyClearPro.dll")]
1743  static extern bool PFC_GetFaceInfo(void* pImageProfile, PFCFBFACEINFO1* pFace, int index);
1744 
1745  [DllImport("PerfectlyClearPro.dll")]
1746  static extern bool PFC_AbnormalTintDetected(void* pImageProfile, TINTCORRECTION eTintMethod);
1747 #endif
1748 
1749 #if ADAPTER32BIT
1750  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1751  static extern int PFC_SetProtectionPath(byte* path);
1752 
1753  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1754  static extern void PFC_ReleaseProtectionPath();
1755 
1756  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1757  static extern PFCENGINE* PFC_CreateEngine();
1758 
1759  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1760  static extern void PFC_DestroyEngine(PFCENGINE* p);
1761 
1762  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1763  static extern void PFC_SetParam(ref PFCPARAM param, PFCPRESETID id);
1764 
1765  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1766  static extern int PFC_ReadPresets(ref PFCPARAM param, byte* filename);
1767 
1768  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1769  static extern int PFC_ReadPresetsFromStream(ref PFCPARAM param, byte* s);
1770 
1771  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1772  static extern PFCIMAGEPROFILE* PFC_Calc(PFCIMAGE* pImage, PFCIMAGE* pImageds, PFCENGINE* pEngine, PFCFEATURE feature, int iISO, byte* pCameraModel, void* pImageProfile, void* progfn, int bRejectMonolith);
1773 
1774  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1775  static extern void PFC_ReleaseProfile(void* pProfile);
1776 
1777  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1778  static extern PFCAPPLYSTATUS PFC_Apply(PFCIMAGE* pImage, PFCENGINE* pEngine, void* pImageProfile, ref PFCPARAM param, void* progfn, int iOpacity);
1779 
1780  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1781  static extern PFCAPPLYSTATUS PFC_ApplyLocal(PFCIMAGE* pImage, int xOffset, int yOffset, int widthOrig, int heightOrig, PFCENGINE* pEngine, PFCIMAGEPROFILE* pImageProfile, ref PFCPARAM param, int iOpacity);
1782 
1783  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1784  static extern bool PFC_HasFaceBeautification(PFCENGINE* pEngine);
1785 
1786  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1787  static extern int PFC_FBFaceCount(void* pImageProfile);
1788 
1789  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1790  static extern bool PFC_GetFaceInfo(void* pImageProfile, PFCFBFACEINFO1* pFace, int index);
1791 
1792  [DllImport("PerfectlyClearPro.dll", CallingConvention = CallingConvention.Cdecl)]
1793  static extern bool PFC_AbnormalTintDetected(void* pImageProfile, TINTCORRECTION eTintMethod);
1794 #endif
1795  }
1796 }
PFCPIXELFORMAT
defines the format of the image data
Legacy structure defining face area detected from the SFB library.
Adjust skin to user defined foundation color.
PFCRE_STATUS
Enumeration defining status of Red Eye pre-calculation.
bool bDCF
Set to TRUE to enable Digital Color Fidelity. Recommended value is FALSE.
Error reading image data.
Skip pre-calculations on Abnormal Tint Correction during Core pre-calculations.
int iTeethLevel
Teeth whitening level. Range 0 to 100.
Process aborted because of insufficient memory.
PFCPIXELFORMAT format
Defines byte order of input buffer.
int iFinishExposure
Exposure correction amount.
Invalid License or validation failed.
int iEnhanceLevel
Eye enhancement level. Range 0 to 100.
PFCAPPLYSTATUS
Enumeration defining return code from the Apply() function.
PFCV3PARAM v3
V3 Corrections.
Full res image (pImage) is missing.
void * pEngine
Pointer to binary definition of the processing engine.
PFCCORE_STATUS CORE_Status
Status code for CORE pre-calc analysis.
Structure encapsulating Noise Removal parameters.
AGGRESSIVENESS eAggressiveness
The desired level of lighting for Automatic Strength Selection to target at the Exposure Correction...
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds)
Overload method for auto correction.
Process cancelled.
PFCRECT face
Bounding rectangle of detected face.
This type of correction provides a more uniform appearance to the complexion. It combines the natural...
PFCREPARAM re
Red Eye Removal.
TINTCORRECTION
Enumeration defining different abnormal tint analysis mode.
TINTCORRECTION eTintMode
ENUM value defined in TINTCORRECTION. It sets the aggressiveness of Tint Removal. ...
Struct describing 3D Lut information.
int iSkinToning
Skin Toning level. Range 0 to 100.
PFCPOINT leftEye
Point of left eye in detected face.
No correction occur during process.
Less aggressive in exposure correction.
int iFinishTint
Tint correction amount.
PFCV3PARAM layer2
params on layers 2 - fiinishing
Feature not enabled.
PFCCOREMask mask0
masks for layer 0
int stride
Byte width of each scanline.
int iBlemish
Blemish removal level. Range 0 to 100.
int iBlush
Blush level. Range 0 to 100.
Pixel format not supported.
bool bEyeCirc
Set to TRUE to enable eye circle removal.
float fTintScale
Scalar value of how much tint correction should be applied. Range 0.0 to 1.0.
Feature not enabled.
int iFinishHighlights
Highlights correction amount.
bool bUseFAE
Set to TRUE (recommended) to enable Face Aware Exposure selection. Recommended exposure will be calcu...
bool bEnabled
Set to TRUE to enable noise removal.
bool GetFaceInfo(ref PFCFBFACEINFO info, int index)
Get face information.
Structure encapsulating Face Beautification parameters.
Noise not found.
int ReadPresetsFromStream(FileStream fs)
Read a preset from a file stream.
Warning. e.g. face not detected.
For average usage.
bool bLightDiffusion
Set to TRUE to enable light diffusion during DCF correction.
Struct PFCSTATUS Process status of all sub sectors.
int AutoCorrect(ref Bitmap bm)
Overload method for auto correction.
This is a more aggressive and effective correction where the appearance of the entire skin (including...
int height
Pixel height of image.
Struct PFCPARAM the master structure of all processing parameters.
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
float height
radial/rounded: h of bounding rect, linear: dist from centerY where grad becomes 1.0.
SKINMODE
Enumeration defining modes in Perfect Smooth analysis.
int ReadPresets(string path)
Read a preset from .preset file.
PFCPIXELFORMAT
defines the format of the image data
Highest sensitivity level of tint detection.
Apply correction ONLY on skin regions included in faces.
int iNeutralDensity
Neutral density filter amout.
Struct defining an PFC engine instance.
Moderate level of tint detection.
PFCPOINT rightEye
Point of right eye in detected face.
Structure encapsulating the CORE processing parameters.
Full res image (pImage) is missing.
PFCNR_STATUS
Enumeration defining status of Noise Removal pre-calculation.
Feature not enabled.
uint status
Status of engine defined in PFCENGINESTATUS. For NO-SFB version the status will always be ENGINESTATU...
LIPSHARPENTYPE eLipSharpenType
See definition of LIPSHARPENTYPE.
bool AbnormalTintDetected(TINTCORRECTION eTintMethod)
Query if Abnormal Tint detected.
Struct defining a rectangle.
Struct PFCPARAM the master structure of all processing parameters.
void * data
Pointer pointing to the first byte of image data buffer.
Whitens (bleaches) face. Recommended mainly for darker skin.
General error.
DCFMODE
Enumeration defining DCF analysis mode.
Fine tuned for Asian skin tone.
Operation cancelled by user.
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature)
Overload method for precalc analysis.
Unable to locate function in the SFBEngine library.
PFCFEATURE
ENUM controlling types of calculations at the pre-calculation stage.
int iPreprocessEV
EV correction amount (Image Ambulace)
Struct defining an PFC engine instance.
Use Fast mode of Face Aware Exposure pre-calculations.
Calculates for all of the above.
int iDetailOffset
Offset to recommended level of preservation of details. Range -30 to 30.
PFCPOINT rightEye
Point of right eye in detected face.
Bitmap ReadImage(string filename)
Utility function for reading image file into Bitmap.
unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm)
Apply correction.
Process cancelled.
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature, int ISO, string CameraModel)
Overload method for precalc analysis.
bool bSkinToning
Set to TRUE to enable skin toning.
Moderate level of exposure correction.
int width
Pixel width of image.
int x
x coordinate of this point.
Apply correction on most skin regions regardless they are linked with a face or not.
int iFinishTemp
Temp correction amount.
bool bTeeth
Set to TRUE to enable teeth whitening.
Struct defining an image to be used in PFC library.
Average usage with brighter tone.
Optimized to bring out more details in the shadows, more details in the highlights, and more pleasing skin tones.
bool bVibrancy
Set to true (recommended default) to enable Color Vibrancy in the library.
Pointer pEngine is NULL.
The face analysis did not complete successfully.
PFCPRESETID
ENUM for presets support by this SDK.
PFCFBPARAM fb
Face Beautification corrections.
float radius
only for MASK_ROUNDRECT - corner radius, relative to image w.
bool bContrast
Set to TRUE to also apply Athentech&#39;s patented Medical Imaging contrast technology.
PFCCOREMask mask2
masks for layer 2
int iFinishSaturation
Saturation correction amount.
int iContrast
Intensity of contrast or depth. Range 0 to 100.
SKINMODE eSmoothMode
Use SKINMODE_FACE to apply correction ONLY on skin regions included in faces. Use SKINMODE_BODY to ap...
AGGRESSIVENESS
Enumeration defining different Auto Exposure calculation modes.
Image side dimension smaller than 32 pixels.
bool bPreprocessEV
Enable EV correction (Image Ambulance)
float feather
relative length of gradient, from where it starts (1.0) to where it is 0.0,
int iColorVibrancy
Color Vibrancy amount.
int left
x in point coordinate of this rect.
int iSlim
Face slimming level. Range 0 to 100.
float width
radial/rounded: w of bounding rect, linear: ignored.
Stronger sharpening. Details are more pronounced.
Priority on minimum false positive detection.
Struct defining an image profile as calculated from PFC_Calc() function.
Monolith source image.
Struct defining an image to be used in PFC library.
PFCFEATURE
ENUM controlling types of calculations at the pre-calculation stage.
float transparency
overall transparency applied to the whole mask (strength 100 means transparency 0.0, 0 -> 1.0).
int iEnlargeLevel
Eye enlargement level. Range 0 to 100.
Feature not enabled.
PFCRE_STATUS RE_Status
Status code for Red Eye pre-calc analysis.
PFC3DLutInfo lutInputSky
LUT data to apply.
PFC3DLutInfo lutOutput
LUT data to apply.
int iStrengthOffset
Offset to recommended level of noise removal strength. Range -5 to 5.
int iDeFlash
Deflash level. Range 0 to 100.
Intelligent Auto.
bool bDynamicRange
Set to TRUE to enable dynamic range correction.
bool bEnlarge
Set to TRUE to enable eye enlargement.
bool bSmooth
Set to TRUE to enable face smoothing.
int iCatchLight
Catchlight level. Range 0 to 100.
bool bUseAutomaticStrengthSelection
Set to TRUE (recommended default) to enable Automatic Strength Selection. Perfectly Clear will determ...
bool invert
invert mask (x = 1.0 - x). NOTE: UI meaning of invert is: if one mask layer set invert = true...
Pointer pImage is NULL.
PFC3DLutInfo lutInputFoliageBrown
LUT data to apply.
int height
height of this rect.
int iVibrancy
Degree of color vibrancy. This value will only be use when bVibrancy is TRUE. Very large values can p...
CONTRASTMODE eContrastMode
Select contrast mode.
bool bEnhance
Set to TRUE to enable eye enhancement.
SKINSMOOTHTYPE eSmoothType
See enum definition of SKINSMOOTHTYPE.
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds)
Overload method for precalc analysis.
Darkens skin, makes it look naturally tanned.
PFCFB_STATUS FB_Status
Status code for Face Beautification pre-calc analysis.
Warms skin tone.
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
float fBiasScale
Scalar value of how much BIAS correction should be applied. Range 0.0 to 1.0.
Error in settings.
bool bLipSharpen
Set to TRUE to enable lip sharpening.
TINTCORRECTION
Enumeration defining different abnormal tint analysis mode.
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature, int ISO, string CameraModel)
Overload method for precalc analysis.
unsigned char * data
Pointer pointing to the first byte of image data buffer.
Process cancelled.
Makes skin look lighter and more pale.
int AutoCorrect(ref Bitmap bm, int ISO, string CameraModel, bool bFastFAE)
Performs auto correction.
SKINTONINGTYPE
Enumeration defining type of Skin Toning correction.
int AutoCorrect(ref Bitmap bm, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
Process cancelled.
Pointer pProfile is NULL.
float fLightDiffusion
Scale value to control intensity of light diffusion correction.
int iLipSharpen
Lip sharpening level. Range 0 to 100.
int iFinishShadows
Shadows correction amount.
float fSharpenScale
Sharpening intensity. This value controls how much sharpening to be applied. Range 0...
Unable to create SFB Engine object for processing.
int y
y coordinate of this point.
bool bAbnormalTintRemoval
Set to true to enable Abnormal Tint Removal. Recommended default is FALSE.
Calculates for Perfectly Clear Core correction.
DCFMODE eDCFMode
Select different class of DCF.
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset)
Overload method for auto correction.
int iSmoothLevel
Face smoothing level. Range 0 to 100.
bool bDeFlash
Set to TRUE to enable deflash.
Red eye not found.
float fDCF
Scale value to control intensity of Digital Color Fidelity correction. Range 0.0 to 1...
LIPSHARPENTYPE
Enumeration defining Lip Sharpening mode.
int iEyeCirc
Eye circle removal level. Range 0 to 100.
bool bInfrared
Set to TRUE (recommended default) to enable infrared correction. It&#39;s a good idea to turn Infrared Co...
SKINTONINGTYPE eSkinToningType
See enum definition of SKINTONINGTYPE.
int iStrength
Set the strength of exposure correction. If Automatic Strength Selection is enabled, the recommended value is put in this variable upon function return. Range 0 to 150.
PerfectlyClear(string path="")
Class constructor.
PFCCOREMask mask1
masks for layer 1
PFCPIXELFORMAT format
Defines byte order of input buffer.
int iFinishWhites
Whites correction amount.
int top
y in point corrdinate of this rect.
Image source in format not supported by this version of API.
PFCCORE_MASK_TYPE type
Mask type.
PFCNR_STATUS NR_Status
Status code for Noise Removal pre-calc analysis.
Calculates for Perfectly Clear Noise Removal.
int iFinishBlacks
Blacks correction amount.
PFC3DLutInfo lutInputFoliageGreen
LUT data to apply.
PFCFB_STATUS
Enumeration defining status of Face Beautification pre-calculation.
unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm, int iOpacity)
Apply correction.
Struct describing V3 parameters.
PFC3DLutInfo lutInputCorrective
LUT data to apply.
SKINMODE eSkinToningMode
Use SKINMODE_FACE to apply correction ONLY on skin regions included in faces. Use SKINMODE_BODY to ap...
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm)
Performs precalc analysis.
PFCAPPLYSTATUS
Enumeration defining return code from the Apply() function.
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature)
Overload method for precalc analysis.
int iFinishVibrancy
Vibrancy correction amount.
bool bSharpen
Set to TRUE to enable sharpening.
PFCPRESETID
ENUM for presets support by this SDK.
PFCV3PARAM layer0
params on layers 0 - top/inside
bool HasFaceBeautification()
Query if Face Beautification feature is available.
Skip Face Aware Exposure pre-calculations during Core pre-calculations.
Class defining face area detected from the SFB library.
The subtle correction removes the wrinkles and spots alone while it keeps the texture of the face unc...
PFCRECT face
Bounding rectangle of detected face.
PFCV3PARAM layer1
params on layers 1 - bottom/outside, 2 - fiinishing
PFCCOREPARAM core
Core corrections to apply.
int iBlackEnhancement
Set luminance threshold for Noise Management. Range 0 to 25.
Face beautification feature not available.
Structure encapsulating Red Eye Correction parameters.
Full res image (pImage) is missing.
BIASMODE
Enumeration defining BIAS analysis mode.
More aggressive in exposure correction.
bool bEnabled
Set to true to enable the entire Core correction.
Full res source image (pImage) is missing.
bool bBlemish
Set to TRUE to enable blemish removal.
Calculates for Red Eye Removal.
void SetParam(PFCPRESETID id)
Set process parameters in current instance.
Fine touch of sharpening.
Insufficient memory.
CONTRASTMODE
Enumeration defining contrast mode.
Turn off bias correction.
bool bBlush
Set to TRUE to add blush.
Lip details are coarsely pronounced.
ADPTRRETURNCODE
General return code.
Struct defining an image profile as calculated from PFC_Calc() function.
int AutoCorrect(ref Bitmap bm, string pathPreset)
Overload method for auto correction.
float fInfrared
Scale value to control intensity of infrared correction. Range 0.0 to 1.0.
Optimized to bring higher contrast to the image.
bool bEnabled
Set to TRUE to enable red eye removal.
PFCCORE_STATUS
Enumeration defining status of Core pre-calculation.
Some warnings during processing.
bool bSlim
Set to TRUE to enable face slimming.
BIASMODE eBiasMode
Skin and depth bias control. Recommended value is BIAS_AVERAGE_PREFERENCE, unless you are printing to...
int iMaxStrength
Use this value to limit the maximum Exposure to be applied on the Automatic Exposure Strength Selecti...
bool bCatchLight
Set to TRUE to enable catchlight removal.
int iFinishContrast
Contrast correction amount.
bool bEnabled
Set to TRUE to enable entire face beautification.
Aggressive detection of tint.
PFCPOINT leftEye
Point of left eye in detected face.
PFCNRPARAM nr
Noise reduction corrections.
Calculates for Face Beautification.
SKINSMOOTHTYPE
Enumeration defining types of Skin Smoothing correction.