Perfectly Clear SDK Documentation  10.7.1.1191
PerfectlyClearAdapter.cs
Go to the documentation of this file.
1 
6 using System;
7 using System.Text;
8 using System.Drawing;
9 using System.Drawing.Drawing2D;
10 using System.Diagnostics;
11 using System.Drawing.Imaging;
12 using System.IO;
13 using System.Runtime.InteropServices;
14 
16 {
18 [StructLayout(LayoutKind.Sequential, Pack = 1)]
19 public struct PFCPOINT
20 {
21  public int x;
22  public int y;
23 };
24 
26 [StructLayout(LayoutKind.Sequential, Pack = 1)]
27 public struct PFCRECT
28 {
29  public int left;
30  public int top;
31  public int width;
32  public int height;
33 };
34 
36 public struct PFCFBFACEINFO1
37 {
38  public PFCPOINT leftEye;
39  public PFCPOINT rightEye;
40  public PFCRECT face;
41 };
42 
44 public class PFCFBFACEINFO
45 {
46  public PFCPOINT leftEye;
47  public PFCPOINT rightEye;
48  public PFCRECT face;
49 
51  public PFCFBFACEINFO()
52  {
53  face.left = 0;
54  face.top = 0;
55  face.width = 0;
56  face.height = 0;
57  leftEye.x = 0;
58  leftEye.y = 0;
59  rightEye.x = 0;
60  rightEye.y = 0;
61  }
62 };
63 
65 [StructLayout(LayoutKind.Sequential, Pack = 1)]
66 public class PFCFACERECT
67 {
68  public PFCRECT rect;
69  public PFCRECT rcEyeL;
70  public PFCRECT rcEyeR;
71  public PFCRECT rcMouth;
72  public PFCPOINT ptEyeL;
73  public PFCPOINT ptEyeR;
74  public int angle;
75  public int blinkLevel;
76  public int blinkLevelL;
77  public int blinkLevelR;
78  public int childLevel;
79  public int confidence;
80  public int smileLevel;
81  public int yawAngle;
82  public int FAE1;
83  public int FAE2;
84  public int FAE3;
85  public int widthImage;
86  public int heightImage;
87  public IntPtr pWrapped;
88 
89  public PFCFACERECT()
90  {
91  pWrapped = IntPtr.Zero;
92  }
93 };
94 
96 public enum PFCFEATURE
97 {
98  CALC_CORE = 1,
99  CALC_NR = 2,
100  CALC_FB = 4,
101  CALC_RE = 8,
102  CALC_ALL = 15,
103  CALC_NOTINTCALC = 16,
104  CALC_NOFAE = 32,
105  CALC_FAEHISPEED = 64,
106  CALC_CARTOON_DETECTOR = 128,
107  CALC_SHARP = 256,
108  CALC_SCENE_DETECTION = 512,
109  CALC_COMPOSITE = 1024,
110  CALC_SKINTONE = 2048,
111  CALC_AICOLOR = 4096
112 
113  };
114 
116 public enum PFCAIFEATURE
117 {
118  AI_SCENE_DETECTION = 1,
119  AI_CORRECTIONS = 2,
120  AI_COMPOSITE = 4,
121  AI_SKINTONE = 8,
122  AI_COLOR = 16,
123  AI_FACEMESH = 32
124  };
125 
127 public enum PFCPIXELFORMAT
128 {
241 };
242 
244 public enum PFCPRESETID
245 {
249  PRESET_VIVID,
256 
257 };
258 
260 public enum PFCNR_STATUS
261 {
270 };
271 
273 public enum PFCCORE_STATUS
274 {
283 };
284 
286 public enum PFCREJECTOPTION
287 {
288  PFC_REJECT_NONE = 0,
289  PFC_REJECT_MONOLITH = 1,
290  PFC_REJECT_CLIPART = 2
291 };
292 
294 public enum PFCFB_STATUS
295 {
307 };
308 
310 public enum PFCRE_STATUS
311 {
321 };
322 
324 public enum PFCAPPLYSTATUS
325 {
326  APPLY_SUCCESS = 0,
329  APPLY_CANCELLED = -3,
330  APPLY_NOSOURCE = -4,
331  APPLY_BADFORMAT = -5,
332  APPLY_INVALIDLICENSE = -6,
338  APPLY_LOOKS_MISSING = -12
339 };
340 
342 public enum TINTCORRECTION
343 {
348 };
349 
351 public enum AGGRESSIVENESS
352 {
353  CONSERVATIVE,
354  MODERATE,
355  AGGRESSIVE,
356 };
357 
359 public enum DCFMODE
360 {
363 };
364 
366 public enum CONTRASTMODE
367 {
368  HIGH_CONTRAST,
370 };
371 
373 public enum BIASMODE
374 {
375  BIAS_NONE,
380  BIAS_AUTO
381 };
382 
384 public enum ADPTRRETURNCODE
385 {
386  SUCCESS,
387  WARNING,
388  INTERNALERROR,
389  WRONG_FORMAT
390 };
391 
393 public enum SKINMODE
394 {
395  SKINMODE_FACE = 1,
397 };
398 
400 public enum SKINSMOOTHTYPE
401 {
405 };
406 
408 public enum SKINTONINGTYPE
409 {
415 };
416 
418 public enum LIPSHARPENTYPE
419 {
420  LIPSHARPENTYPE_FINE = 1,
423 };
424 
426 [StructLayout(LayoutKind.Sequential, Pack = 1)]
427 public struct SELECTIVECOLOR
428 {
429  public int r;
430  public int a;
431  public int m;
432  public int p;
433  public int H;
434  public int S;
435  public int L;
436 };
437 
439 public struct PFCCOREPARAM
440 {
441  public bool bEnabled;
442  public bool bAbnormalTintRemoval;
444  public float fTintScale;
445  public int iBlackEnhancement;
446  public bool bVibrancy;
447  public int iVibrancy;
448  public int iStrength;
449  public bool bContrast;
451  public int iContrast;
453  public float fBiasScale;
456  public bool bSharpen;
457  public float fSharpenScale;
459  public bool bUseFAE;
461  public int iMaxStrength;
462  public bool bInfrared;
463  public float fInfrared;
464  public bool bLightDiffusion;
465  public float fLightDiffusion;
466  public bool bDynamicRange;
467  public bool bDCF;
468  public DCFMODE eDCFMode;
469  public float fDCF;
470  public int iLocalContrast;
471  public bool bLocalContrast;
472  public int iMinStrength;
473  public int iSkintoneType;
474  public int iSkintoneStrengthLut;
476  public bool bSkintoneAuto;
478  public int iSplitColorWarm;
479  public int iSplitColorCold;
480  public bool bSelectiveColor;
489  };
490 
492 public struct PFCFBPARAM
493 {
494  public bool bEnabled;
495  public bool bSmooth;
496  public int iSmoothLevel;
499  public bool bEnlarge;
500  public int iEnlargeLevel;
501  public bool bEnhance;
502  public int iEnhanceLevel;
503  public bool bEyeCirc;
504  public int iEyeCirc;
505  public bool bTeeth;
506  public int iTeethLevel;
507  public bool bBlemish;
508  public int iBlemish;
509  public bool bSlim;
510  public int iSlim;
511  public bool bDeFlash;
512  public int iDeFlash;
513  public bool bCatchLight;
514  public int iCatchLight;
515  public int iCatchLightMode;
516  public bool bSkinToning;
523  public int iSkinToning;
526  public bool bLipSharpen;
527  public int iLipSharpen;
529  public bool bBlush;
530  public int iBlush;
531  public uint colorSkinToning;
532  public uint colorBlush;
533 };
534 
536 public unsafe struct PFCNRPARAM
537 {
538  public bool bEnabled;
539  public int iPreset;
540  public int iStrengthOffset;
548  public int iDetailOffset;
549 };
550 
552 public struct PFCREPARAM
553 {
554  public bool bEnabled;
555 };
556 
557 // V3 additions
558 public enum PFCCORE_MASK_TYPE
559 {
560  PFCCORE_MASK_NONE, // 0.0 everywhere, don't apply
561  PFCCORE_MASK_ALL, // 1.0 everywhere (background)
562  PFCCORE_MASK_RADIAL, // ellipse
563  PFCCORE_MASK_TOP, // linear from 1.0 on top
564  PFCCORE_MASK_BOTTOM, // linear from 1.0 on bottom
565  PFCCORE_MASK_ROUNDRECT // rounded rect
566 };
567 
568 /* Description of mask for grad filter, all coordinates are relative (Y/height, X/width) in final crop-rotated image */
572 public unsafe struct PFCCOREMask
573 {
574  public PFCCORE_MASK_TYPE type;
575  public float centerX;
576  public float centerY;
577  public float width;
578  public float height;
579  public float radius;
580  public float feather;
581  public float angle;
582  public float transparency;
583  [MarshalAsAttribute(UnmanagedType.I1)]
584  public bool invert;
585 };
586 
587 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
589 public struct PFC3DLutInfo
590 {
591  [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 33)]
592  public string guid;
593 
594  public byte strength; // C++ unsigned char
595 }
596 
598 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
599 public unsafe struct PFCV3PARAM
600 {
601  // Image Ambulance
602  [MarshalAsAttribute(UnmanagedType.I1)]
603  public bool bPreprocessEV;
604  public int iPreprocessEV;
605  // built-in 3D luts
606  public int iNeutralDensity;
607  public int iColorVibrancy;
608  public int iDarkSkin;
613  // custom output 3D Lut
615  // Finishing
616  public int iFinishTemp;
617  public int iFinishTint;
618  public int iFinishExposure;
619  public int iFinishBlacks;
620  public int iFinishShadows;
621  public int iFinishHighlights;
622  public int iFinishWhites;
623  public int iFinishSaturation;
624  public int iFinishVibrancy;
625  public int iFinishContrast;
627 
628  public int iDeltaR;
629  public int iDeltaG;
630  public int iDeltaB;
631 
632  public bool bDynamic;
633  public int iDynamic;
634  public int iDynamicWB;
635 
636  public int iOutLUTcontrast;
637  public int iOutLUTsaturation;
638 };
639 
641 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
642 public unsafe struct DP2PARAM
643 {
644  public int iDensity;
645  public int iDeltaR;
646  public int iDeltaG;
647  public int iDeltaB;
648  public float fGamma;
649  public int iContrast;
650  public int iSaturation;
651  public int mode;
652  public bool bAuto;
653  public bool bEnable;
654 };
655 
656  [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
658 public struct PFCPARAM
659 {
661  public PFCFBPARAM fb;
662  public PFCNRPARAM nr;
663  public PFCREPARAM re;
664  public PFCV3PARAM v3;
671  public DP2PARAM dp2;
672  };
673 
675 public struct PFCSTATUS
676 {
677  public PFCCORE_STATUS CORE_Status;
678  public PFCNR_STATUS NR_Status;
679  public PFCFB_STATUS FB_Status;
680  public PFCRE_STATUS RE_Status;
681  public int Status;
682 }
683 
684 [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
686 public struct PFCSCENEDESCRIPTION
687  {
688  [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 250)]
689  public string name;
690 
691  public int profileUUID; // C++ unsigned char
692 }
693 
700  public unsafe class PerfectlyClear : IDisposable
701  {
703  protected unsafe struct PFCENGINE
704  {
705  void* pEngine;
706  public uint status;
707  };
709  protected unsafe struct PerfectlyClearImageTransfer
710  {
711  public int width;
712  public int height;
713  public int rowBytes;
714  public int columnBytes;
715  public int data1;
716  public int data2;
717  public int data3;
718  };
719 
721  protected unsafe struct PFCIMAGEPROFILE
722  {
723  void* pPfcParam;
724  void* pNoiseParam;
725  void* pRedEyeParam;
726  void* pSFBParam;
727  void* pInternal;
728 
733 
734  public int Status;
735  };
742 
744  protected unsafe struct PFCIMAGE
745  {
746  public int width;
747  public int height;
748  public int stride;
750  public void* data;
751  };
752 
753 
754  protected PFCENGINE* m_pEngine;
755  protected PFCENGINE* m_pAiEngine;
756  int m_loadedAiEngineFeatures;
757  protected PFCIMAGEPROFILE* m_pProfile;
758  public PFCPARAM m_Param;
759  public PFCSTATUS LastStatus;
760  public PFCSTATUS LastAiStatus;
761  private bool releaseProtection = false;
762 
796  public static int SetProtectionPath(string path, string licenseCode)
797  {
798 #if PROTECTION_ENABLED
799  try
800  {
801  byte* pLicpath = null;
802  if (!String.IsNullOrEmpty(path))
803  {
804  pLicpath = GetCharBuffer(path);
805  }
806 
807  byte* pLicenseCode = null;
808  if (!String.IsNullOrEmpty(licenseCode)) {
809  pLicenseCode = GetCharBuffer(licenseCode);
810  }
811 
812  int status = PFC_SetProtectionPath(pLicpath, pLicenseCode);
813 
814  FreeCharBuffer(pLicpath);
815  FreeCharBuffer(pLicenseCode);
816  //Trace.WriteLine("status " + status.ToString());
817 
818  return status;
819  }
820  catch (Exception ex)
821  {
822  Trace.WriteLine(ex.Message);
823  return 100;
824  }
825 #endif
826  return 0;
827  }
828 
829 
835  public static void ReleaseProtectionPath()
836  {
837  PFC_ReleaseProtectionPath();
838  }
839 
846  public PerfectlyClear()
847  {
848  m_pEngine = null;
849  m_pProfile = null;
850  m_pAiEngine = null;
851  m_loadedAiEngineFeatures = 0;
852 
853  try
854  {
855  m_pEngine = PFC_CreateEngine();
856  if (m_pEngine != null)
857  {
858  LastStatus.Status = (int)(*m_pEngine).status;
859  }
860 
861  m_pAiEngine = PFC_CreateEngine();
862  if (m_pAiEngine != null)
863  {
864  LastAiStatus.Status = (int)(*m_pAiEngine).status;
865  }
866  }
867  catch (Exception ex)
868  {
869  Trace.WriteLine(ex.Message);
870  }
871 
872  PFC_SetParam(ref m_Param, PFCPRESETID.PRESET_IAUTO_PEOPLE);
873  }
874 
884  public PerfectlyClear(string path, string licenseCode = "")
885  {
886  m_pEngine = null;
887  m_pProfile = null;
888 
889 #if PROTECTION_ENABLED
890  try
891  {
892  byte* pLicpath = null;
893  if (!String.IsNullOrEmpty(path))
894  {
895  pLicpath = GetCharBuffer(path);
896  }
897 
898  byte* pLicenseCode = null;
899  if (!String.IsNullOrEmpty(licenseCode)) {
900  pLicenseCode = GetCharBuffer(licenseCode);
901  }
902 
903  int status = PFC_SetProtectionPath(pLicpath, pLicenseCode);
904  releaseProtection = true;
905 
906  FreeCharBuffer(pLicpath);
907  FreeCharBuffer(pLicenseCode);
908  //Trace.WriteLine("status " + status.ToString());
909  }
910  catch (Exception ex)
911  {
912  Trace.WriteLine(ex.Message);
913  }
914 #endif
915  try
916  {
917  m_pEngine = PFC_CreateEngine();
918  if (m_pEngine != null)
919  {
920  LastStatus.Status = (int)(*m_pEngine).status;
921  }
922 
923  m_pAiEngine = PFC_CreateEngine();
924  if (m_pAiEngine != null)
925  {
926  LastAiStatus.Status = (int)(*m_pAiEngine).status;
927  }
928  }
929  catch (Exception ex)
930  {
931  Trace.WriteLine(ex.Message);
932  }
933 
934  PFC_SetParam(ref m_Param, PFCPRESETID.PRESET_IAUTO_21);
935  }
936 
937  ~PerfectlyClear()
938  {
939 #if PROTECTION_ENABLED
940  if(releaseProtection) {
942  }
943 #endif
944  Dispose(false);
945  }
946 
952  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm)
953  {
954  return Calc(ref bm, PFCFEATURE.CALC_ALL, -1, null);
955  }
956 
962  public unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile)
963  {
964  return Calc(ref imgfile, PFCFEATURE.CALC_ALL, -1, null);
965  }
966 
973  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds)
974  {
975  return Calc(ref bm, ref bmds, PFCFEATURE.CALC_ALL, -1, null);
976  }
977 
984  public unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile, PFCFEATURE feature)
985  {
986  return Calc(ref imgfile, feature, -1, null);
987  }
988 
995  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature)
996  {
997  return Calc(ref bm, feature, -1, null);
998  }
999 
1007  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature)
1008  {
1009  return Calc(ref bm, ref bmds, feature, -1, null);
1010  }
1011 
1021  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature, int ISO, string CameraModel, PFCREJECTOPTION rejectOption = PFCREJECTOPTION.PFC_REJECT_CLIPART)
1022  {
1023  BitmapData bd = null;
1024  Byte* pBase = null;
1025  bd = LockBitmapData(ref bm);
1026  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
1027  bd.PixelFormat != PixelFormat.Format32bppArgb &&
1028  bd.PixelFormat != PixelFormat.Format48bppRgb &&
1029  bd.PixelFormat != PixelFormat.Format64bppArgb)
1030  {
1031  ReleaseBitmapData(ref bm, ref bd);
1032  return ADPTRRETURNCODE.WRONG_FORMAT;
1033  }
1034  pBase = (Byte*)bd.Scan0.ToPointer();
1035 
1036  PFCIMAGE im;
1037  im.width = bd.Width;
1038  im.height = bd.Height;
1039  im.stride = bd.Stride;
1040  switch (bd.PixelFormat)
1041  {
1042  default:
1043  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
1044  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
1045  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
1046  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
1047  }
1048  im.data = (void*)pBase;
1049 
1050  if (m_pProfile != null)
1051  PFC_ReleaseProfile(m_pProfile);
1052 
1053  byte* pModel = null;
1054  if (CameraModel != null)
1055  {
1056  pModel = GetCharBuffer(CameraModel);
1057  }
1058  m_pProfile = PFC_Calc(&im, null, m_pEngine, feature, ISO, pModel, null, null, (int)rejectOption, m_pAiEngine);
1059 
1060  FreeCharBuffer(pModel);
1061 
1062  ReleaseBitmapData(ref bm, ref bd);
1063 
1064  LastStatus.NR_Status = (*m_pProfile).NR_Status;
1065  LastStatus.CORE_Status = (*m_pProfile).CORE_Status;
1066  LastStatus.FB_Status = (*m_pProfile).FB_Status;
1067  LastStatus.RE_Status = (*m_pProfile).RE_Status;
1068  LastStatus.Status = (*m_pProfile).Status;
1069 
1070  return (LastStatus.Status == 0) ? ADPTRRETURNCODE.SUCCESS : ADPTRRETURNCODE.WARNING;
1071  }
1072 
1082  public unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile, PFCFEATURE feature, int ISO, string CameraModel, PFCREJECTOPTION rejectOption = PFCREJECTOPTION.PFC_REJECT_CLIPART)
1083  {
1084  PFCIMAGE im;
1085  im.width = imgfile.width();
1086  im.height = imgfile.height();
1087  im.stride = imgfile.stride();
1088  im.format = (PFCPIXELFORMAT)imgfile.pfcImageFormat();
1089  im.data = (void*)imgfile.raw_image();
1090 
1091  if (m_pProfile != null)
1092  PFC_ReleaseProfile(m_pProfile);
1093 
1094  byte* pModel = null;
1095  if (CameraModel != null)
1096  {
1097  pModel = GetCharBuffer(CameraModel);
1098  }
1099  m_pProfile = PFC_Calc(&im, null, m_pEngine, feature, ISO, pModel, null, null, (int)rejectOption, m_pAiEngine);
1100 
1101  FreeCharBuffer(pModel);
1102 
1103  LastStatus.NR_Status = (*m_pProfile).NR_Status;
1104  LastStatus.CORE_Status = (*m_pProfile).CORE_Status;
1105  LastStatus.FB_Status = (*m_pProfile).FB_Status;
1106  LastStatus.RE_Status = (*m_pProfile).RE_Status;
1107  LastStatus.Status = (*m_pProfile).Status;
1108 
1109  return (LastStatus.Status == 0) ? ADPTRRETURNCODE.SUCCESS : ADPTRRETURNCODE.WARNING;
1110  }
1111 
1121  public unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature, int ISO, string CameraModel)
1122  {
1123  BitmapData bd = null;
1124  Byte* pBase = null;
1125  bd = LockBitmapData(ref bm);
1126  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
1127  bd.PixelFormat != PixelFormat.Format32bppArgb &&
1128  bd.PixelFormat != PixelFormat.Format48bppRgb &&
1129  bd.PixelFormat != PixelFormat.Format64bppArgb)
1130  {
1131  ReleaseBitmapData(ref bm, ref bd);
1132  return ADPTRRETURNCODE.WRONG_FORMAT;
1133  }
1134  pBase = (Byte*)bd.Scan0.ToPointer();
1135 
1136  PFCIMAGE im;
1137  im.width = bd.Width;
1138  im.height = bd.Height;
1139  im.stride = bd.Stride;
1140  switch (bd.PixelFormat)
1141  {
1142  default:
1143  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
1144  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
1145  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
1146  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
1147  }
1148  im.data = (void*)pBase;
1149 
1150  BitmapData bdds = null;
1151  bdds = LockBitmapData(ref bmds);
1152  if (bdds.PixelFormat != PixelFormat.Format24bppRgb &&
1153  bdds.PixelFormat != PixelFormat.Format32bppArgb &&
1154  bdds.PixelFormat != PixelFormat.Format48bppRgb &&
1155  bdds.PixelFormat != PixelFormat.Format64bppArgb)
1156  {
1157  ReleaseBitmapData(ref bmds, ref bdds);
1158  return ADPTRRETURNCODE.WRONG_FORMAT;
1159  }
1160  pBase = (Byte*)bdds.Scan0.ToPointer();
1161 
1162  PFCIMAGE imds;
1163  imds.width = bdds.Width;
1164  imds.height = bdds.Height;
1165  imds.stride = bdds.Stride;
1166  switch (bdds.PixelFormat)
1167  {
1168  default:
1169  case PixelFormat.Format24bppRgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
1170  case PixelFormat.Format32bppArgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
1171  case PixelFormat.Format48bppRgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
1172  case PixelFormat.Format64bppArgb: imds.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
1173  }
1174  imds.data = (void*)pBase;
1175 
1176  if (m_pProfile != null)
1177  PFC_ReleaseProfile(m_pProfile);
1178 
1179  byte* pModel = null;
1180  if (CameraModel != null)
1181  {
1182  pModel = GetCharBuffer(CameraModel);
1183  }
1184  m_pProfile = PFC_Calc(&im, &imds, m_pEngine, feature, ISO, pModel, null, null, 1, m_pAiEngine);
1185 
1186  FreeCharBuffer(pModel);
1187 
1188  ReleaseBitmapData(ref bm, ref bd);
1189  ReleaseBitmapData(ref bmds, ref bdds);
1190 
1191  LastStatus.NR_Status = (*m_pProfile).NR_Status;
1192  LastStatus.CORE_Status = (*m_pProfile).CORE_Status;
1193  LastStatus.FB_Status = (*m_pProfile).FB_Status;
1194  LastStatus.RE_Status = (*m_pProfile).RE_Status;
1195  LastStatus.Status = (*m_pProfile).Status;
1196 
1197  return (LastStatus.Status == 0) ? ADPTRRETURNCODE.SUCCESS : ADPTRRETURNCODE.WARNING;
1198  }
1199 
1206  public unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm)
1207  {
1208  return Apply(ref bm, 100);
1209  }
1210 
1216  public unsafe PFCAPPLYSTATUS Apply(ref PFCImageFile imgfile)
1217  {
1218  return Apply(ref imgfile, 100);
1219  }
1220 
1227  public unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm, int iOpacity)
1228  {
1229  if (m_pProfile == null)
1230  {
1231  return PFCAPPLYSTATUS.APPLY_ERROR_PROFILE_MISSING;
1232  }
1233 
1234  BitmapData bd = null;
1235  Byte* pBase = null;
1236  bd = LockBitmapData(ref bm);
1237  if (bd.PixelFormat != PixelFormat.Format24bppRgb &&
1238  bd.PixelFormat != PixelFormat.Format32bppArgb &&
1239  bd.PixelFormat != PixelFormat.Format48bppRgb &&
1240  bd.PixelFormat != PixelFormat.Format64bppArgb)
1241  {
1242  ReleaseBitmapData(ref bm, ref bd);
1243  return PFCAPPLYSTATUS.APPLY_BADFORMAT;
1244  }
1245  pBase = (Byte*)bd.Scan0.ToPointer();
1246 
1247  PFCIMAGE im;
1248  im.width = bd.Width;
1249  im.height = bd.Height;
1250  im.stride = bd.Stride;
1251  switch (bd.PixelFormat)
1252  {
1253  default:
1254  case PixelFormat.Format24bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat24bppRGB; break;
1255  case PixelFormat.Format32bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat32bppARGB; break;
1256  case PixelFormat.Format48bppRgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat48bppRGB; break;
1257  case PixelFormat.Format64bppArgb: im.format = PFCPIXELFORMAT.PFC_PixelFormat64bppARGB; break;
1258  }
1259  im.data = (void*)pBase;
1260 
1261  PFCAPPLYSTATUS ret = PFC_Apply(&im, m_pEngine, m_pProfile, ref m_Param, null, iOpacity, null);
1262 
1263  if (ret > 0)
1264  {
1265  int code = (int)ret;
1266  // Get individual return codes
1267  LastStatus.NR_Status = (PFCNR_STATUS)(code & 0x000000FF);
1268  LastStatus.CORE_Status = (PFCCORE_STATUS)((code >> 8) & 0x000000FF);
1269  LastStatus.FB_Status = (PFCFB_STATUS)((code >> 16) & 0x000000FF);
1270  LastStatus.RE_Status = (PFCRE_STATUS)((code >> 24) & 0x000000FF);
1271  LastStatus.Status = code;
1272  }
1273 
1274  ReleaseBitmapData(ref bm, ref bd);
1275  return ret;
1276  }
1277 
1284  public unsafe PFCAPPLYSTATUS Apply(ref PFCImageFile imgfile, int iOpacity)
1285  {
1286  if (m_pProfile == null)
1287  {
1288  return PFCAPPLYSTATUS.APPLY_ERROR_PROFILE_MISSING;
1289  }
1290 
1291  PFCIMAGE im;
1292  im.width = imgfile.width();
1293  im.height = imgfile.height();
1294  im.stride = imgfile.stride();
1295  im.format = (PFCPIXELFORMAT)imgfile.pfcImageFormat();
1296  im.data = (void*)imgfile.raw_image();
1297 
1298  PFCAPPLYSTATUS ret = PFC_Apply(&im, m_pEngine, m_pProfile, ref m_Param, null, iOpacity, null);
1299 
1300  if (ret > 0)
1301  {
1302  int code = (int)ret;
1303  // Get individual return codes
1304  LastStatus.NR_Status = (PFCNR_STATUS)(code & 0x000000FF);
1305  LastStatus.CORE_Status = (PFCCORE_STATUS)((code >> 8) & 0x000000FF);
1306  LastStatus.FB_Status = (PFCFB_STATUS)((code >> 16) & 0x000000FF);
1307  LastStatus.RE_Status = (PFCRE_STATUS)((code >> 24) & 0x000000FF);
1308  LastStatus.Status = code;
1309  }
1310 
1311  return ret;
1312  }
1313 
1345  public int AutoCorrect(ref Bitmap bm)
1346  {
1347  return AutoCorrect(ref bm, -1, null, false);
1348  }
1349 
1355  public int AutoCorrect(ref PFCImageFile imgfile)
1356  {
1357  return AutoCorrect(ref imgfile, -1, null, false);
1358  }
1359 
1367  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds)
1368  {
1369  return AutoCorrect(ref bm, ref bmds, -1, null, false);
1370  }
1371 
1380  public int AutoCorrect(ref Bitmap bm, int ISO, string CameraModel, bool bFastFAE)
1381  {
1382  if(((PFCAIFEATURE)m_loadedAiEngineFeatures & PFCAIFEATURE.AI_SCENE_DETECTION) == PFCAIFEATURE.AI_SCENE_DETECTION) {
1383  ADPTRRETURNCODE sdRet = Calc(ref bm, PFCFEATURE.CALC_SCENE_DETECTION, ISO, CameraModel);
1384  if (sdRet == ADPTRRETURNCODE.SUCCESS) {
1385  int version = 0;
1386  int detectedCategory = GetScene(&version);
1387  if (detectedCategory >= 0) {
1388  PFCPARAM categoryParam = new PFCPARAM();
1389  if (0 == ReadScenePreset(ref categoryParam, detectedCategory)) {
1390  m_Param = categoryParam;
1391  }
1392  }
1393  }
1394  }
1395 
1396  PFCFEATURE feature = 0;
1397  if (m_Param.nr.bEnabled)
1398  feature |= PFCFEATURE.CALC_NR;
1399  if (m_Param.core.bEnabled)
1400  feature |= PFCFEATURE.CALC_CORE;
1401  if (m_Param.fb.bEnabled)
1402  feature |= PFCFEATURE.CALC_FB;
1403  if (m_Param.re.bEnabled)
1404  feature |= PFCFEATURE.CALC_RE;
1405  if (!m_Param.core.bAbnormalTintRemoval)
1406  feature |= PFCFEATURE.CALC_NOTINTCALC;
1407  // Any FAE optimization
1408  if (m_Param.core.bUseFAE)
1409  {
1410  if (bFastFAE)
1411  feature |= PFCFEATURE.CALC_FAEHISPEED;
1412  }
1413  else
1414  {
1415  feature |= PFCFEATURE.CALC_NOFAE;
1416  }
1417  if (m_Param.core.bSkintoneAuto)
1418  {
1419  feature |= PFCFEATURE.CALC_SCENE_DETECTION;
1420  }
1421  if (m_Param.dp2.bEnable && m_Param.dp2.bAuto)
1422  {
1423  feature |= PFCFEATURE.CALC_AICOLOR;
1424  }
1425 
1426  ADPTRRETURNCODE ret = Calc(ref bm, feature, ISO, CameraModel);
1427 
1428  if (ret != ADPTRRETURNCODE.SUCCESS)
1429  {
1430  PFCNR_STATUS retNR = LastStatus.NR_Status;
1431  if (retNR == PFCNR_STATUS.PFC_NR_NOTFOUND || retNR == PFCNR_STATUS.PFC_NR_NOTENABLED)
1432  retNR = PFCNR_STATUS.PFC_NR_SUCCESS;
1433 
1434  PFCCORE_STATUS retCORE = LastStatus.CORE_Status;
1435  if (retCORE == PFCCORE_STATUS.PFC_CORE_NOTENABLED)
1436  retCORE = PFCCORE_STATUS.PFC_CORE_SUCCESS;
1437 
1438  PFCFB_STATUS retFB = LastStatus.FB_Status;
1439  if (retFB == PFCFB_STATUS.PFC_FB_NOTENABLED || retFB == PFCFB_STATUS.PFC_FB_WARNING)
1440  retFB = PFCFB_STATUS.PFC_FB_SUCCESS;
1441 
1442  PFCRE_STATUS retRE = LastStatus.RE_Status;
1443  if (retRE == PFCRE_STATUS.PFC_RE_NOTENABLED || retRE == PFCRE_STATUS.PFC_RE_NOT_FOUND)
1444  retRE = PFCRE_STATUS.PFC_RE_SUCCESS;
1445 
1446  int retInt = (((((((int)retRE << 8) | (int)retFB) << 8) | (int)retCORE) << 8) | (int)retNR);
1447  return retInt;
1448  }
1449  else
1450  {
1451  PFCAPPLYSTATUS aret = Apply(ref bm);
1452  return (int)aret;
1453  }
1454  }
1455 
1464  public int AutoCorrect(ref PFCImageFile imgfile, int ISO, string CameraModel, bool bFastFAE)
1465  {
1466  if(((PFCAIFEATURE)m_loadedAiEngineFeatures & PFCAIFEATURE.AI_SCENE_DETECTION) == PFCAIFEATURE.AI_SCENE_DETECTION) {
1467  ADPTRRETURNCODE sdRet = Calc(ref imgfile, PFCFEATURE.CALC_SCENE_DETECTION, ISO, CameraModel);
1468  if (sdRet == ADPTRRETURNCODE.SUCCESS) {
1469  int version = 0;
1470  int detectedCategory = GetScene(&version);
1471  if (detectedCategory >= 0) {
1472  PFCPARAM categoryParam = new PFCPARAM();
1473  if (0 == ReadScenePreset(ref categoryParam, detectedCategory)) {
1474  m_Param = categoryParam;
1475  }
1476  }
1477  }
1478  }
1479 
1480  PFCFEATURE feature = 0;
1481  if (m_Param.nr.bEnabled)
1482  feature |= PFCFEATURE.CALC_NR;
1483  if (m_Param.core.bEnabled)
1484  feature |= PFCFEATURE.CALC_CORE;
1485  if (m_Param.fb.bEnabled)
1486  feature |= PFCFEATURE.CALC_FB;
1487  if (m_Param.re.bEnabled)
1488  feature |= PFCFEATURE.CALC_RE;
1489  if (!m_Param.core.bAbnormalTintRemoval)
1490  feature |= PFCFEATURE.CALC_NOTINTCALC;
1491  // Any FAE optimization
1492  if (m_Param.core.bUseFAE)
1493  {
1494  if (bFastFAE)
1495  feature |= PFCFEATURE.CALC_FAEHISPEED;
1496  }
1497  else
1498  {
1499  feature |= PFCFEATURE.CALC_NOFAE;
1500  }
1501  if (m_Param.core.bSkintoneAuto)
1502  {
1503  feature |= PFCFEATURE.CALC_SCENE_DETECTION;
1504  }
1505  if (m_Param.dp2.bEnable && m_Param.dp2.bAuto)
1506  {
1507  feature |= PFCFEATURE.CALC_AICOLOR;
1508  }
1509 
1510  ADPTRRETURNCODE ret = Calc(ref imgfile, feature, ISO, CameraModel);
1511 
1512  if (ret != ADPTRRETURNCODE.SUCCESS)
1513  {
1514  PFCNR_STATUS retNR = LastStatus.NR_Status;
1515  if (retNR == PFCNR_STATUS.PFC_NR_NOTFOUND || retNR == PFCNR_STATUS.PFC_NR_NOTENABLED)
1516  retNR = PFCNR_STATUS.PFC_NR_SUCCESS;
1517 
1518  PFCCORE_STATUS retCORE = LastStatus.CORE_Status;
1519  if (retCORE == PFCCORE_STATUS.PFC_CORE_NOTENABLED)
1520  retCORE = PFCCORE_STATUS.PFC_CORE_SUCCESS;
1521 
1522  PFCFB_STATUS retFB = LastStatus.FB_Status;
1523  if (retFB == PFCFB_STATUS.PFC_FB_NOTENABLED || retFB == PFCFB_STATUS.PFC_FB_WARNING)
1524  retFB = PFCFB_STATUS.PFC_FB_SUCCESS;
1525 
1526  PFCRE_STATUS retRE = LastStatus.RE_Status;
1527  if (retRE == PFCRE_STATUS.PFC_RE_NOTENABLED || retRE == PFCRE_STATUS.PFC_RE_NOT_FOUND)
1528  retRE = PFCRE_STATUS.PFC_RE_SUCCESS;
1529 
1530  int retInt = (((((((int)retRE << 8) | (int)retFB) << 8) | (int)retCORE) << 8) | (int)retNR);
1531  return retInt;
1532  }
1533  else
1534  {
1535  PFCAPPLYSTATUS aret = Apply(ref imgfile);
1536  return (int)aret;
1537  }
1538  }
1539 
1549  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, int ISO, string CameraModel, bool bFastFAE)
1550  {
1551  if(((PFCAIFEATURE)m_loadedAiEngineFeatures & PFCAIFEATURE.AI_SCENE_DETECTION) == PFCAIFEATURE.AI_SCENE_DETECTION) {
1552  ADPTRRETURNCODE sdRet = Calc(ref bm, PFCFEATURE.CALC_SCENE_DETECTION, ISO, CameraModel);
1553  if (sdRet == ADPTRRETURNCODE.SUCCESS) {
1554  int version = 0;
1555  int detectedCategory = GetScene(&version);
1556  if (detectedCategory >= 0) {
1557  PFCPARAM categoryParam = new PFCPARAM();
1558  if (0 == ReadScenePreset(ref categoryParam, detectedCategory)) {
1559  m_Param = categoryParam;
1560  }
1561  }
1562  }
1563  }
1564 
1565  PFCFEATURE feature = 0;
1566  if (m_Param.nr.bEnabled)
1567  feature |= PFCFEATURE.CALC_NR;
1568  if (m_Param.core.bEnabled)
1569  feature |= PFCFEATURE.CALC_CORE;
1570  if (m_Param.fb.bEnabled)
1571  feature |= PFCFEATURE.CALC_FB;
1572  if (m_Param.re.bEnabled)
1573  feature |= PFCFEATURE.CALC_RE;
1574  if (!m_Param.core.bAbnormalTintRemoval)
1575  feature |= PFCFEATURE.CALC_NOTINTCALC;
1576  // Any FAE optimization
1577  if (m_Param.core.bUseFAE)
1578  {
1579  if (bFastFAE)
1580  feature |= PFCFEATURE.CALC_FAEHISPEED;
1581  }
1582  else
1583  {
1584  feature |= PFCFEATURE.CALC_NOFAE;
1585  }
1586  if (m_Param.core.bSkintoneAuto)
1587  {
1588  feature |= PFCFEATURE.CALC_SCENE_DETECTION;
1589  }
1590  if (m_Param.dp2.bEnable && m_Param.dp2.bAuto)
1591  {
1592  feature |= PFCFEATURE.CALC_AICOLOR;
1593  }
1594 
1595  ADPTRRETURNCODE ret = Calc(ref bm, ref bmds, feature, ISO, CameraModel);
1596 
1597  if (ret != ADPTRRETURNCODE.SUCCESS)
1598  {
1599  PFCNR_STATUS retNR = LastStatus.NR_Status;
1600  if (retNR == PFCNR_STATUS.PFC_NR_NOTFOUND || retNR == PFCNR_STATUS.PFC_NR_NOTENABLED)
1601  retNR = PFCNR_STATUS.PFC_NR_SUCCESS;
1602 
1603  PFCCORE_STATUS retCORE = LastStatus.CORE_Status;
1604  if (retCORE == PFCCORE_STATUS.PFC_CORE_NOTENABLED)
1605  retCORE = PFCCORE_STATUS.PFC_CORE_SUCCESS;
1606 
1607  PFCFB_STATUS retFB = LastStatus.FB_Status;
1608  if (retFB == PFCFB_STATUS.PFC_FB_NOTENABLED || retFB == PFCFB_STATUS.PFC_FB_WARNING)
1609  retFB = PFCFB_STATUS.PFC_FB_SUCCESS;
1610 
1611  PFCRE_STATUS retRE = LastStatus.RE_Status;
1612  if (retRE == PFCRE_STATUS.PFC_RE_NOTENABLED || retRE == PFCRE_STATUS.PFC_RE_NOT_FOUND)
1613  retRE = PFCRE_STATUS.PFC_RE_SUCCESS;
1614 
1615  int retInt = (((((((int)retRE << 8) | (int)retFB) << 8) | (int)retCORE) << 8) | (int)retNR);
1616  return retInt;
1617  }
1618  else
1619  {
1620  PFCAPPLYSTATUS aret = Apply(ref bm);
1621  return (int)aret;
1622  }
1623  }
1624 
1631  public int AutoCorrect(ref Bitmap bm, string pathPreset)
1632  {
1633  int retCode = ReadPresets(pathPreset);
1634  if (retCode == 0)
1635  {
1636  return AutoCorrect(ref bm, -1, null, false);
1637  }
1638  return retCode-1000;
1639  }
1640 
1647  public int AutoCorrect(ref PFCImageFile imgfile, string pathPreset)
1648  {
1649  int retCode = ReadPresets(pathPreset);
1650  if (retCode == 0)
1651  {
1652  return AutoCorrect(ref imgfile, -1, null, false);
1653  }
1654  return retCode - 1000;
1655  }
1656 
1664  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset)
1665  {
1666  int retCode = ReadPresets(pathPreset);
1667  if (retCode == 0)
1668  {
1669  return AutoCorrect(ref bm, ref bmds, -1, null, false);
1670  }
1671  return retCode - 1000;
1672  }
1673 
1683  public int AutoCorrect(ref Bitmap bm, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
1684  {
1685  int retCode = ReadPresets(pathPreset);
1686  if (retCode == 0)
1687  {
1688  return AutoCorrect(ref bm, ISO, CameraModel, bFastFAE);
1689  }
1690  return retCode - 1000;
1691  }
1692 
1702  public int AutoCorrect(ref PFCImageFile imgfile, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
1703  {
1704  int retCode = ReadPresets(pathPreset);
1705  if (retCode == 0)
1706  {
1707  return AutoCorrect(ref imgfile, ISO, CameraModel, bFastFAE);
1708  }
1709  return retCode - 1000;
1710  }
1711 
1722  public int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
1723  {
1724  int retCode = ReadPresets(pathPreset);
1725  if (retCode == 0)
1726  {
1727  return AutoCorrect(ref bm, ref bmds, ISO, CameraModel, bFastFAE);
1728  }
1729  return retCode - 1000;
1730  }
1731 
1736  public void SetParam(PFCPRESETID id)
1737  {
1738  PFC_SetParam(ref m_Param, id);
1739  }
1740 
1760  public int ReadPresets(string path)
1761  {
1762  try
1763  {
1764  byte* presetpath = null;
1765  if (path != null)
1766  {
1767  presetpath = GetCharBuffer(path);
1768  }
1769 
1770  int status = PFC_ReadPresets(ref m_Param, presetpath);
1771  //Trace.WriteLine("status " + status.ToString());
1772  return status;
1773  }
1774  catch (Exception ex)
1775  {
1776  Trace.WriteLine(ex.Message);
1777  }
1778  return -8;
1779  }
1780 
1795  public int ReadPresetsFromStream(FileStream fs)
1796  {
1797  try
1798  {
1799  long len = fs.Length;
1800  byte[] buffer = new byte[len + 1];
1801  int size = (int)len;
1802  fs.Read(buffer, 0, size);
1803  buffer[size] = 0;
1804  byte* b = GetCharBuffer(buffer);
1805  // PFC_ReadPresetsFromStream return codes
1806  // 0 - success
1807  // -3 - Stream read error.
1808  // -4 - Parse error.
1809  int status = PFC_ReadPresetsFromStream(ref m_Param, b);
1810  FreeCharBuffer(b);
1811  return status;
1812  }
1813  catch (Exception ex)
1814  {
1815  Trace.WriteLine(ex.Message);
1816  }
1817  return -8;
1818  }
1819 
1837  public int LoadScenePresetsFromStream(FileStream fs, int groupUUID = 0, int* arrProfileUUID = null, int arrProfileUUIDLen = 0)
1838  {
1839  try
1840  {
1841  long len = fs.Length;
1842  byte[] buffer = new byte[len + 1];
1843  int size = (int)len;
1844  fs.Read(buffer, 0, size);
1845  buffer[size] = 0;
1846  byte* b = GetCharBuffer(buffer);
1847  int status = PFC_LoadScenePresetsFromStream(m_pAiEngine, b, size, groupUUID, arrProfileUUID, arrProfileUUIDLen);
1848  FreeCharBuffer(b);
1849  return status;
1850  }
1851  catch (Exception ex)
1852  {
1853  Trace.WriteLine(ex.Message);
1854  }
1855  return -8;
1856  }
1857 
1863  {
1864  return PFC_HasFaceBeautification(m_pEngine);
1865  }
1866 
1872  public int FBFaceCount()
1873  {
1874  return PFC_FBFaceCount(m_pProfile);
1875  }
1876 
1885  public bool GetFaceInfo(ref PFCFBFACEINFO info, int index)
1886  {
1887  PFCFBFACEINFO1 fi;
1888  bool ret = PFC_GetFaceInfo(m_pProfile, &fi, index);
1889  info.face.left = fi.face.left;
1890  info.face.top = fi.face.top;
1891  info.face.width = fi.face.width;
1892  info.face.height = fi.face.height;
1893  info.leftEye.x = fi.leftEye.x;
1894  info.leftEye.y = fi.leftEye.y;
1895  info.rightEye.x = fi.rightEye.x;
1896  info.rightEye.y = fi.rightEye.y;
1897  return ret;
1898  }
1899 
1905  public bool AbnormalTintDetected(TINTCORRECTION eTintMethod)
1906  {
1907  return PFC_AbnormalTintDetected(m_pProfile, eTintMethod);
1908  }
1909 
1915  public void ApplyStrengthToParam(int strength)
1916  {
1917  PFC_ApplyStrengthToParam(ref m_Param, strength);
1918  }
1919 
1920  protected BitmapData LockBitmapData(ref Bitmap bm)
1921  {
1922  GraphicsUnit unit = GraphicsUnit.Pixel;
1923  RectangleF boundsF = bm.GetBounds(ref unit);
1924  Rectangle bounds = new Rectangle((int)boundsF.X,
1925  (int)boundsF.Y,
1926  (int)boundsF.Width,
1927  (int)boundsF.Height);
1928 
1929  BitmapData bitmapData =
1930  bm.LockBits(bounds, ImageLockMode.ReadWrite, bm.PixelFormat);
1931  return bitmapData;
1932  }
1933 
1934  protected void ReleaseBitmapData(ref Bitmap bm, ref BitmapData bitmapData)
1935  {
1936  bm.UnlockBits(bitmapData);
1937  }
1938 
1939  protected Bitmap DupBitmap(ref Bitmap bm)
1940  {
1941  PerfectlyClearImageTransfer tr, tr1;
1942  Byte* pBase = null;
1943  GraphicsUnit unit = GraphicsUnit.Pixel;
1944  RectangleF boundsF = bm.GetBounds(ref unit);
1945  Rectangle bounds = new Rectangle((int)boundsF.X,
1946  (int)boundsF.Y,
1947  (int)boundsF.Width,
1948  (int)boundsF.Height);
1949  BitmapData bd = bm.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
1950  Bitmap bm1 = new Bitmap(bd.Width, bd.Height, PixelFormat.Format24bppRgb);
1951  BitmapData bd1 = LockBitmapData(ref bm1);
1952  pBase = (Byte*)bd.Scan0.ToPointer();
1953  tr.columnBytes = (bd.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
1954  tr.rowBytes = bd.Stride;
1955  tr.height = bd.Height;
1956  tr.width = bd.Width;
1957  tr.data1 = (int)(pBase + 2);
1958  tr.data2 = (int)(pBase + 1);
1959  tr.data3 = (int)pBase;
1960  pBase = (Byte*)bd1.Scan0.ToPointer();
1961  tr1.columnBytes = (bd1.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
1962  tr1.rowBytes = bd1.Stride;
1963  tr1.height = bd1.Height;
1964  tr1.width = bd1.Width;
1965  tr1.data1 = (int)(pBase + 2);
1966  tr1.data2 = (int)(pBase + 1);
1967  tr1.data3 = (int)pBase;
1968  for (int i = 0; i < tr.height; i++)
1969  {
1970  for (int j = 0; j < tr.width; j++)
1971  {
1972  ((Byte*)tr1.data1)[j * tr1.columnBytes] = ((Byte*)tr.data1)[j * tr.columnBytes];
1973  ((Byte*)tr1.data2)[j * tr1.columnBytes] = ((Byte*)tr.data2)[j * tr.columnBytes];
1974  ((Byte*)tr1.data3)[j * tr1.columnBytes] = ((Byte*)tr.data3)[j * tr.columnBytes];
1975  }
1976  tr.data1 += (int)tr.rowBytes;
1977  tr.data2 += (int)tr.rowBytes;
1978  tr.data3 += (int)tr.rowBytes;
1979  tr1.data1 += (int)tr1.rowBytes;
1980  tr1.data2 += (int)tr1.rowBytes;
1981  tr1.data3 += (int)tr1.rowBytes;
1982  }
1983  ReleaseBitmapData(ref bm1, ref bd1);
1984  ReleaseBitmapData(ref bm, ref bd);
1985  return bm1;
1986  }
1987 
1988  protected Bitmap BW2RGB(ref Bitmap bm)
1989  {
1990  Byte* pBase = null;
1991  Byte* pBase1 = null;
1992  GraphicsUnit unit = GraphicsUnit.Pixel;
1993  RectangleF boundsF = bm.GetBounds(ref unit);
1994  Rectangle bounds = new Rectangle((int)boundsF.X,
1995  (int)boundsF.Y,
1996  (int)boundsF.Width,
1997  (int)boundsF.Height);
1998  BitmapData bd = bm.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
1999  Bitmap bm1 = new Bitmap(bd.Width, bd.Height, PixelFormat.Format24bppRgb);
2000  BitmapData bd1 = LockBitmapData(ref bm1);
2001  pBase = (Byte*)bd.Scan0.ToPointer();
2002  pBase1 = (Byte*)bd1.Scan0.ToPointer();
2003  for (int i = 0; i < bd.Height; i++)
2004  {
2005  for (int j = 0; j < bd.Width; j++)
2006  {
2007  pBase1[j * 3] = pBase[j];
2008  pBase1[j * 3 + 1] = pBase[j];
2009  pBase1[j * 3 + 2] = pBase[j];
2010  }
2011  pBase += bd.Stride;
2012  pBase1 += bd1.Stride;
2013  }
2014  ReleaseBitmapData(ref bm1, ref bd1);
2015  ReleaseBitmapData(ref bm, ref bd);
2016  return bm1;
2017  }
2018 
2026  public Bitmap ReadImage(string filename)
2027  {
2028  Bitmap bm = null;
2029  Bitmap myBitmap = new Bitmap(filename);
2030  if ((myBitmap.Flags & (int)ImageFlags.ColorSpaceYcck) != 0)
2031  {
2032  bm = DupBitmap(ref myBitmap);
2033  myBitmap.Dispose();
2034  }
2035  else
2036  {
2037  if (myBitmap.PixelFormat == PixelFormat.Format8bppIndexed)
2038  {
2039  bm = BW2RGB(ref myBitmap);
2040  myBitmap.Dispose();
2041  }
2042  else
2043  {
2044  bm = myBitmap;
2045  }
2046  }
2047  return bm;
2048  }
2049 
2050  protected Bitmap GetStatImage(ref Bitmap bm, int iMaxDimension)
2051  {
2052  // Build max dim reference image
2053  bool bNeedResize = true;
2054  int w, h, w1, h1;
2055  w = bm.Width;
2056  h = bm.Height;
2057  // Calculate size of reference image. One dimension is 1024.
2058  if (w > h)
2059  {
2060  if (w <= iMaxDimension)
2061  bNeedResize = false;
2062  w1 = iMaxDimension;
2063  h1 = w1 * h / w;
2064  }
2065  else
2066  {
2067  if (h <= iMaxDimension)
2068  bNeedResize = false;
2069  h1 = iMaxDimension;
2070  w1 = h1 * w / h;
2071  }
2072 
2073  if (bNeedResize)
2074  {
2075  //
2076  // Step 2.
2077  // Create temporary bitmap to assist red eye analysis.
2078  //
2079  Bitmap bmds = new Bitmap(w1, h1, bm.PixelFormat);
2080  {
2081  using (Graphics gr = Graphics.FromImage(bmds))
2082  {
2083  gr.SmoothingMode = SmoothingMode.HighQuality;
2084  gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
2085  gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
2086  gr.DrawImage(bm, new Rectangle(0, 0, w1, h1));
2087  }
2088  }
2089 
2090  return bmds;
2091  }
2092  else
2093  {
2094  Bitmap bmds = (Bitmap)bm.Clone();
2095  return bmds;
2096  }
2097  }
2098 
2118  public unsafe bool EnumFAEFaceRect(ref PFCFACERECT rect)
2119  {
2120  IntPtr wrapped = rect.pWrapped;
2121  IntPtr pRect = (IntPtr) PFC_EnumFAEFaceRect(m_pProfile, (void*)wrapped);
2122 
2123  if (pRect != IntPtr.Zero) {
2124  PFCFACERECT newRect = (PFCFACERECT) Marshal.PtrToStructure(pRect, typeof(PFCFACERECT));
2125  rect = newRect;
2126  rect.pWrapped = (IntPtr)pRect;
2127  return true;
2128  }
2129 
2130  rect.pWrapped = IntPtr.Zero;
2131  return false;
2132  }
2133 
2138  public int FAEFaceCount()
2139  {
2140  return PFC_FAEFaceCount(m_pProfile);
2141  }
2142 
2149  public int LoadAiEngine(PFCAIFEATURE aifeatures, string binPath)
2150  {
2151  byte* path = null;
2152  if (binPath != null)
2153  {
2154  path = GetCharBuffer(binPath);
2155  }
2156  int result = PFC_LoadAIEngine(m_pAiEngine, aifeatures, path);
2157  m_loadedAiEngineFeatures = result;
2158 
2159  if(((PFCAIFEATURE)m_loadedAiEngineFeatures & PFCAIFEATURE.AI_CORRECTIONS) == PFCAIFEATURE.AI_CORRECTIONS) {
2160  PFC_LoadAIEngine(m_pEngine, PFCAIFEATURE.AI_CORRECTIONS, path);
2161  }
2162 
2163  FreeCharBuffer(path);
2164 
2165  if(((PFCAIFEATURE)m_loadedAiEngineFeatures & PFCAIFEATURE.AI_SCENE_DETECTION) == PFCAIFEATURE.AI_SCENE_DETECTION) {
2166  LoadScenePresets(null);
2167  }
2168 
2169  return result;
2170  }
2171 
2172 
2183  public unsafe int LoadScenePresets(string filePath, int groupUUID = 0, int* arrProfileUUID = null, int arrProfileUUIDLen = 0)
2184  {
2185  byte* path = null;
2186  if (filePath != null)
2187  {
2188  path = GetCharBuffer(filePath);
2189  }
2190  int result = PFC_LoadScenePresets(m_pAiEngine, path, groupUUID, arrProfileUUID, arrProfileUUIDLen);
2191  FreeCharBuffer(path);
2192  return result;
2193  }
2194 
2202  public int ReadScenePreset(ref PFCPARAM param, int scene)
2203  {
2204  return PFC_ReadScenePreset(ref param, m_pAiEngine, scene);
2205  }
2206 
2213  public int GetScene(int* version)
2214  {
2215  return PFC_GetScene(m_pProfile, version);
2216  }
2217 
2226  public bool GetCategorizationEngineInfo(int* groupUUID, int* arrProfileUUID, int* arrProfileUUIDLen)
2227  {
2228  return PFC_GetSceneDetectionEngineInfo(m_pAiEngine, groupUUID, arrProfileUUID, arrProfileUUIDLen);
2229  }
2230 
2234  static public void SetAddonPath(string dirPath)
2235  {
2236  byte* path = null;
2237  if (dirPath != null)
2238  {
2239  path = GetCharBuffer(dirPath);
2240  }
2241  PFC_SetAddonPath(path);
2242  FreeCharBuffer(path);
2243  }
2244 
2261  public bool GetSceneDescription(int index, ref PFCSCENEDESCRIPTION sceneDescription)
2262  {
2263  bool result = PFC_GetSceneDescription(m_pAiEngine, index, ref sceneDescription);
2264  return result;
2265  }
2266 
2267  public void Dispose()
2268  {
2269  Dispose(true);
2270  GC.SuppressFinalize(this);
2271  }
2272 
2273  protected virtual void Dispose(bool disposing)
2274  {
2275  if (disposing)
2276  {
2277  }
2278 
2279  if (m_pProfile != null)
2280  {
2281  PFC_ReleaseProfile(m_pProfile);
2282  m_pProfile = null;
2283  }
2284 
2285  if (m_pEngine != null)
2286  {
2287  PFC_DestroyEngine(m_pEngine);
2288  m_pEngine = null;
2289  }
2290 
2291  if (m_pAiEngine != null)
2292  {
2293  PFC_DestroyEngine(m_pAiEngine);
2294  m_pEngine = null;
2295  }
2296  }
2297 
2298  static protected byte* GetCharBuffer(byte[] s)
2299  {
2300  int i, iCount = s.Length;
2301  IntPtr _memory = IntPtr.Zero;
2302  _memory = Marshal.AllocHGlobal(iCount + 1);
2303  byte* p = (byte*)_memory;
2304  for (i = 0; i < iCount; i++)
2305  {
2306  p[i] = (byte)s[i];
2307  }
2308  p[iCount] = 0;
2309 
2310  return (byte*)p;
2311  }
2312 
2313  static protected byte* GetCharBuffer(string s)
2314  {
2315  int i, iCount = s.Length;
2316  IntPtr _memory = IntPtr.Zero;
2317  _memory = Marshal.AllocHGlobal(iCount + 1);
2318  byte* p = (byte*)_memory;
2319  for (i = 0; i < iCount; i++)
2320  {
2321  p[i] = (byte)s[i];
2322  }
2323  p[iCount] = 0;
2324 
2325  return (byte*)p;
2326  }
2327 
2328  static protected void FreeCharBuffer(byte* p)
2329  {
2330  IntPtr _memory = (IntPtr)p;
2331  Marshal.FreeHGlobal(_memory);
2332  }
2333 
2334 #if ADAPTER64BIT
2335  [DllImport("PerfectlyClearPro")]
2336  static extern int PFC_SetProtectionPath(byte* path, byte* licenseCode);
2337 
2338  [DllImport("PerfectlyClearPro")]
2339  static extern void PFC_ReleaseProtectionPath();
2340 
2341  [DllImport("PerfectlyClearPro")]
2342  static extern PFCENGINE* PFC_CreateEngine();
2343 
2344  [DllImport("PerfectlyClearPro")]
2345  static extern void PFC_DestroyEngine(PFCENGINE* p);
2346 
2347  [DllImport("PerfectlyClearPro")]
2348  static extern void PFC_SetParam(ref PFCPARAM param, PFCPRESETID id);
2349 
2350  [DllImport("PerfectlyClearPro")]
2351  static extern int PFC_ReadPresets(ref PFCPARAM param, byte* filename);
2352 
2353  [DllImport("PerfectlyClearPro")]
2354  static extern int PFC_ReadPresetsFromStream(ref PFCPARAM param, byte* s);
2355 
2356  [DllImport("PerfectlyClearPro")]
2357  static extern PFCIMAGEPROFILE* PFC_Calc(PFCIMAGE* pImage, PFCIMAGE* pImageds, PFCENGINE* pEngine, PFCFEATURE feature, int iISO, byte* pCameraModel, void* pImageProfile, void* progfn, int iRejectOption, PFCENGINE* pEngineAI);
2358 
2359  [DllImport("PerfectlyClearPro")]
2360  static extern void PFC_ReleaseProfile(void* pProfile);
2361 
2362  [DllImport("PerfectlyClearPro")]
2363  static extern PFCAPPLYSTATUS PFC_Apply(PFCIMAGE* pImage, PFCENGINE* pEngine, void* pImageProfile, ref PFCPARAM param, void* progfn, int iOpacity, void* pBGProfile);
2364 
2365  [DllImport("PerfectlyClearPro")]
2366  static extern bool PFC_HasFaceBeautification(PFCENGINE* pEngine);
2367 
2368  [DllImport("PerfectlyClearPro")]
2369  static extern int PFC_FBFaceCount(void* pImageProfile);
2370 
2371  [DllImport("PerfectlyClearPro")]
2372  static extern bool PFC_GetFaceInfo(void* pImageProfile, PFCFBFACEINFO1* pFace, int index);
2373 
2374  [DllImport("PerfectlyClearPro")]
2375  static extern bool PFC_AbnormalTintDetected(void* pImageProfile, TINTCORRECTION eTintMethod);
2376 
2377  [DllImport("PerfectlyClearPro")]
2378  static extern void PFC_ApplyStrengthToParam(ref PFCPARAM param, int strength);
2379 
2380  [DllImport("PerfectlyClearPro")]
2381  static extern void* PFC_EnumFAEFaceRect(void *pImageProfile, void* p);
2382 
2383  [DllImport("PerfectlyClearPro")]
2384  static extern int PFC_FAEFaceCount(void* pImageProfile);
2385 
2386  [DllImport("PerfectlyClearPro")]
2387  static extern int PFC_LoadAIEngine(PFCENGINE* pEngineAI, PFCAIFEATURE aifeatures, byte *binPath);
2388 
2389  [DllImport("PerfectlyClearPro")]
2390  static extern int PFC_LoadScenePresets(PFCENGINE* pEngine, byte *filePath, int groupUUID, int *arrProfileUUID, int arrProfileUUIDLen);
2391 
2392  [DllImport("PerfectlyClearPro")]
2393  static extern int PFC_ReadScenePreset(ref PFCPARAM param, PFCENGINE *pEngineAI, int scene);
2394 
2395  [DllImport("PerfectlyClearPro")]
2396  static extern int PFC_GetScene(void* precalc, int *version);
2397 
2398  [DllImport("PerfectlyClearPro")]
2399  static extern bool PFC_GetSceneDetectionEngineInfo(PFCENGINE* pEngine, int* groupUUID, int* arrProfileUUID, int *arrProfileUUIDLen);
2400 
2401  [DllImport("PerfectlyClearPro")]
2402  static extern void PFC_SetAddonPath(byte* path);
2403 
2404  [DllImport("PerfectlyClearPro")]
2405  static extern bool PFC_GetSceneDescription(PFCENGINE* p, int index, ref PFCSCENEDESCRIPTION description);
2406 
2407  [DllImport("PerfectlyClearPro")]
2408  static extern int PFC_LoadScenePresetsFromStream(PFCENGINE* pEngine, byte *buf, int lenBuf, int groupUUID, int *arrProfileUUID, int arrProfileUUIDLen);
2409 #endif
2410 
2411 #if ADAPTER32BIT
2412  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2413  static extern int PFC_SetProtectionPath(byte* path, byte* licenseCode);
2414 
2415  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2416  static extern void PFC_ReleaseProtectionPath();
2417 
2418  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2419  static extern PFCENGINE* PFC_CreateEngine();
2420 
2421  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2422  static extern void PFC_DestroyEngine(PFCENGINE* p);
2423 
2424  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2425  static extern void PFC_SetParam(ref PFCPARAM param, PFCPRESETID id);
2426 
2427  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2428  static extern int PFC_ReadPresets(ref PFCPARAM param, byte* filename);
2429 
2430  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2431  static extern int PFC_ReadPresetsFromStream(ref PFCPARAM param, byte* s);
2432 
2433  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2434  static extern PFCIMAGEPROFILE* PFC_Calc(PFCIMAGE* pImage, PFCIMAGE* pImageds, PFCENGINE* pEngine, PFCFEATURE feature, int iISO, byte* pCameraModel, void* pImageProfile, void* progfn, int iRejectOption, PFCENGINE* pEngineAI);
2435 
2436  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2437  static extern void PFC_ReleaseProfile(void* pProfile);
2438 
2439  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2440  static extern PFCAPPLYSTATUS PFC_Apply(PFCIMAGE* pImage, PFCENGINE* pEngine, void* pImageProfile, ref PFCPARAM param, void* progfn, int iOpacity, void* pBGProfile);
2441 
2442  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2443  static extern bool PFC_HasFaceBeautification(PFCENGINE* pEngine);
2444 
2445  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2446  static extern int PFC_FBFaceCount(void* pImageProfile);
2447 
2448  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2449  static extern bool PFC_GetFaceInfo(void* pImageProfile, PFCFBFACEINFO1* pFace, int index);
2450 
2451  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2452  static extern bool PFC_AbnormalTintDetected(void* pImageProfile, TINTCORRECTION eTintMethod);
2453 
2454  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2455  static extern void PFC_ApplyStrengthToParam(ref PFCPARAM param, int strength);
2456 
2457  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2458  static extern void* PFC_EnumFAEFaceRect(void *pImageProfile, void* p);
2459 
2460  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2461  static extern int PFC_FAEFaceCount(void* pImageProfile);
2462 
2463  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2464  static extern int PFC_LoadAIEngine(PFCENGINE* pEngineAI, PFCAIFEATURE aifeatures, byte *binPath);
2465 
2466  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2467  static extern int PFC_LoadScenePresets(PFCENGINE* pEngine, byte *filePath, int groupUUID, int *arrProfileUUID, int arrProfileUUIDLen);
2468 
2469  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2470  static extern int PFC_ReadScenePreset(ref PFCPARAM param, PFCENGINE *pEngineAI, int scene);
2471 
2472  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2473  static extern int PFC_GetScene(void* precalc, int *version);
2474 
2475  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2476  static extern bool PFC_GetSceneDetectionEngineInfo(PFCENGINE* pEngine, int* groupUUID, int* arrProfileUUID, int* arrProfileUUIDLen);
2477 
2478  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2479  static extern void PFC_SetAddonPath(byte* path);
2480 
2481  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2482  static extern unsafe bool PFC_GetSceneDescription(PFCENGINE* p, int index, ref PFCSCENEDESCRIPTION description);
2483 
2484  [DllImport("PerfectlyClearPro", CallingConvention = CallingConvention.Cdecl)]
2485  static extern int PFC_LoadScenePresetsFromStream(PFCENGINE* pEngine, byte *buf, int lenBuf, int groupUUID, int *arrProfileUUID, int arrProfileUUIDLen);
2486 #endif
2487  }
2488 
2489 
2525  public unsafe class PFCImageFile : IDisposable
2526  {
2527  private IntPtr m_pNativeObject;
2528 
2530  public PFCImageFile()
2531  {
2532  m_pNativeObject = create_PFCImageFile();
2533  }
2534 
2535  public void Dispose()
2536  {
2537  Dispose(true);
2538  }
2539 
2540  protected virtual void Dispose(bool bDisposing)
2541  {
2542  if (this.m_pNativeObject != IntPtr.Zero)
2543  {
2544  delete_PFCImageFile(m_pNativeObject);
2545  m_pNativeObject = IntPtr.Zero;
2546  }
2547 
2548  if (bDisposing)
2549  {
2550  // No need to call the finalizer since we've now cleaned
2551  // up the unmanaged memory
2552  GC.SuppressFinalize(this);
2553  }
2554  }
2555 
2556  ~PFCImageFile()
2557  {
2558  Dispose(false);
2559  }
2560 
2563  {
2564  LOAD_OK,
2565  LOAD_ERROR,
2568  };
2569 
2571  public enum PFC_FILETYPE
2572  {
2573  PFC_JPEG = 1,
2574  PFC_PNG = 2
2575  };
2576 
2584  public PFC_FILE_LOAD_STATUS LoadImage(string filename, bool bConvertToSRGB = false, string iccFolderPath = null)
2585  {
2586  if (filename == null)
2587  {
2588  return PFC_FILE_LOAD_STATUS.LOAD_ERROR;
2589  }
2590 
2591  byte* pFilename = GetCharBuffer(filename);
2592 
2593  byte* pIccFolderPath = null;
2594  if (iccFolderPath != null)
2595  {
2596  pIccFolderPath = GetCharBuffer(iccFolderPath);
2597  }
2598 
2599  int result = PFCImageFile_LoadImageFile(m_pNativeObject, pFilename, bConvertToSRGB, pIccFolderPath);
2600 
2601  FreeCharBuffer(pFilename);
2602  FreeCharBuffer(pIccFolderPath);
2603 
2604  return (PFC_FILE_LOAD_STATUS)result;
2605  }
2606 
2615  public PFC_FILE_LOAD_STATUS LoadImage(string filename, PFC_FILETYPE type, bool bConvertToSRGB = true, string iccFolderPath = null)
2616  {
2617  if (filename == null)
2618  {
2619  return PFC_FILE_LOAD_STATUS.LOAD_ERROR;
2620  }
2621 
2622  byte* pFilename = GetCharBuffer(filename);
2623 
2624  byte* pIccFolderPath = null;
2625  if (iccFolderPath != null)
2626  {
2627  pIccFolderPath = GetCharBuffer(iccFolderPath);
2628  }
2629 
2630  int result = PFCImageFile_LoadImageFileType(m_pNativeObject, pFilename, (int)type, bConvertToSRGB, pIccFolderPath);
2631 
2632  FreeCharBuffer(pFilename);
2633  FreeCharBuffer(pIccFolderPath);
2634 
2635  return (PFC_FILE_LOAD_STATUS)result;
2636  }
2637 
2645  public bool SaveImageFile(string filename, int jpegQuality = 92, bool bConvertToOriginalColorSpace= true, bool bEmbedOriginalMetadata = true)
2646  {
2647  if (filename == null)
2648  {
2649  return false;
2650  }
2651 
2652  byte* pFilename = GetCharBuffer(filename);
2653 
2654  bool result = PFCImageFile_SaveImageFile(m_pNativeObject, pFilename, jpegQuality, bConvertToOriginalColorSpace, bEmbedOriginalMetadata);
2655 
2656  FreeCharBuffer(pFilename);
2657 
2658  return result;
2659  }
2660 
2669  public bool SaveImageFile(string filename, PFC_FILETYPE type, int jpegQuality = 92, bool bConvertToOriginalColorSpace = true, bool bEmbedOriginalMetadata = true)
2670  {
2671  if (filename == null)
2672  {
2673  return false;
2674  }
2675 
2676  byte* pFilename = GetCharBuffer(filename);
2677 
2678  bool result = PFCImageFile_SaveImageFileType(m_pNativeObject, pFilename, (int)type, jpegQuality, bConvertToOriginalColorSpace, bEmbedOriginalMetadata);
2679 
2680  FreeCharBuffer(pFilename);
2681 
2682  return result;
2683  }
2684 
2685  public void AllocBuffer(int width, int height, int bytes_per_pixel, int stride)
2686  {
2687  PFCImageFile_AllocBuffer(m_pNativeObject, width, height, bytes_per_pixel, stride);
2688  }
2689 
2690  public int pfcImageFormat()
2691  {
2692  return PFCImageFile_pfcImageFormat(m_pNativeObject);
2693  }
2694 
2695  public int exifOrientation()
2696  {
2697  return PFCImageFile_exifOrientation(m_pNativeObject);
2698  }
2699 
2700  public byte* raw_image()
2701  {
2702  return PFCImageFile_get_raw_image(m_pNativeObject);
2703  }
2704 
2705  public int width()
2706  {
2707  return PFCImageFile_get_width(m_pNativeObject);
2708  }
2709 
2710  public int height()
2711  {
2712  return PFCImageFile_get_height(m_pNativeObject);
2713  }
2714 
2715  public int bytes_per_pixel()
2716  {
2717  return PFCImageFile_get_bytes_per_pixel(m_pNativeObject);
2718  }
2719 
2720  public int stride()
2721  {
2722  return PFCImageFile_get_stride(m_pNativeObject);
2723  }
2724 
2725  public bool sourceSRGB()
2726  {
2727  return PFCImageFile_get_sourceSRGB(m_pNativeObject);
2728  }
2729 
2738  public PFC_FILE_LOAD_STATUS ExpandImageBuffer(MemoryStream inStream, PFC_FILETYPE type, bool bConvertToSRGB = true, string iccFolderPath = null)
2739  {
2740  byte* buffer = GetByteBuffer(inStream.ToArray());
2741  byte* pIccFolderPath = null;
2742  if (iccFolderPath != null)
2743  {
2744  pIccFolderPath = GetCharBuffer(iccFolderPath);
2745  }
2746  int result = PFCImageFile_ExpandImageBuffer(m_pNativeObject, buffer, inStream.Length, (int)type, bConvertToSRGB, pIccFolderPath);
2747  FreeCharBuffer(pIccFolderPath);
2748  FreeByteBuffer(buffer);
2749 
2750  return (PFC_FILE_LOAD_STATUS)result;
2751  }
2752 
2761  public MemoryStream CompressImageBuffer(PFC_FILETYPE type, int jpegQuality = 92, bool bConvertToOriginalColorSpace = true, bool bEmbedOriginalMetadata = true)
2762  {
2763  byte* compressedBuffer = null;
2764  int length = PFCImageFile_CompressImageBuffer(m_pNativeObject, &compressedBuffer, (int)type, jpegQuality, bConvertToOriginalColorSpace, bEmbedOriginalMetadata);
2765  if (length > 0 && compressedBuffer != null)
2766  {
2767  byte[] result = new byte[length];
2768  Marshal.Copy((IntPtr)(compressedBuffer), result, 0, length);
2769  deleteBuffer(compressedBuffer);
2770 
2771  // let the stream be resizable
2772  MemoryStream stream = new MemoryStream();
2773  stream.Write(result, 0, result.Length);
2774  return stream;
2775  }
2776  return new MemoryStream();
2777  }
2778 
2779  private static byte* GetCharBuffer(string s)
2780  {
2781  UTF8Encoding utf8 = new UTF8Encoding();
2782  Byte[] encodedBytes = utf8.GetBytes(s);
2783 
2784  int i, iCount = encodedBytes.Length;
2785  IntPtr _memory = IntPtr.Zero;
2786  _memory = Marshal.AllocHGlobal(iCount + 1);
2787  byte* p = (byte*)_memory;
2788  for (i = 0; i < iCount; i++)
2789  {
2790  p[i] = encodedBytes[i];
2791  }
2792  p[iCount] = 0;
2793 
2794  return (byte*)p;
2795  }
2796 
2797  private static void FreeCharBuffer(byte* p)
2798  {
2799  IntPtr _memory = (IntPtr)p;
2800  Marshal.FreeHGlobal(_memory);
2801  }
2802 
2803  private static byte* GetByteBuffer(byte[] bytes)
2804  {
2805  int length = bytes.Length;
2806  IntPtr p = Marshal.AllocHGlobal(length);
2807  Marshal.Copy(bytes, 0, p, length);
2808  return (byte*)p;
2809  }
2810 
2811  private static void FreeByteBuffer(byte* p)
2812  {
2813  IntPtr _memory = (IntPtr)p;
2814  Marshal.FreeHGlobal(_memory);
2815  }
2816 
2817 #if ADAPTER64BIT
2818  [DllImport("PFCImageFile")]
2819  static private extern unsafe IntPtr create_PFCImageFile();
2820 
2821  [DllImport("PFCImageFile")]
2822  static private extern void delete_PFCImageFile(IntPtr o);
2823 
2824  [DllImport("PFCImageFile")]
2825  static private extern unsafe int PFCImageFile_LoadImageFile(IntPtr o, byte* filename, bool bConvertToSRGB, byte* iccFolderPath);
2826 
2827  [DllImport("PFCImageFile")]
2828  static private extern unsafe int PFCImageFile_LoadImageFileType(IntPtr o, byte* filename, int type, bool bConvertToSRGB, byte* iccFolderPath);
2829 
2830  [DllImport("PFCImageFile")]
2831  static private extern unsafe bool PFCImageFile_SaveImageFile(IntPtr ptr, byte* filename, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2832 
2833  [DllImport("PFCImageFile")]
2834  static private extern unsafe bool PFCImageFile_SaveImageFileType(IntPtr ptr, byte* filename, int type, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2835 
2836  [DllImport("PFCImageFile")]
2837  static private extern unsafe void PFCImageFile_AllocBuffer(IntPtr ptr, int width, int height, int bytes_per_pixel, int stride);
2838 
2839  [DllImport("PFCImageFile")]
2840  static private extern unsafe int PFCImageFile_pfcImageFormat(IntPtr ptr);
2841 
2842  [DllImport("PFCImageFile")]
2843  static private extern unsafe int PFCImageFile_exifOrientation(IntPtr ptr);
2844 
2845  [DllImport("PFCImageFile")]
2846  static private extern unsafe byte* PFCImageFile_get_raw_image(IntPtr ptr);
2847 
2848  [DllImport("PFCImageFile")]
2849  static private extern unsafe int PFCImageFile_get_width(IntPtr ptr);
2850 
2851  [DllImport("PFCImageFile")]
2852  static private extern unsafe int PFCImageFile_get_height(IntPtr ptr);
2853 
2854  [DllImport("PFCImageFile")]
2855  static private extern unsafe int PFCImageFile_get_bytes_per_pixel(IntPtr ptr);
2856 
2857  [DllImport("PFCImageFile")]
2858  static private extern unsafe int PFCImageFile_get_stride(IntPtr ptr);
2859 
2860  [DllImport("PFCImageFile")]
2861  static private extern unsafe bool PFCImageFile_get_sourceSRGB(IntPtr ptr);
2862 
2863  [DllImport("PFCImageFile")]
2864  static private extern unsafe int PFCImageFile_ExpandImageBuffer(IntPtr ptr, byte* buffer, long size, int type, bool bConvertToSRGB, byte* iccFolderPath);
2865 
2866  [DllImport("PFCImageFile")]
2867  static private extern unsafe int PFCImageFile_CompressImageBuffer(IntPtr ptr, byte** destination, int type, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2868 
2869  [DllImport("PFCImageFile")]
2870  static private extern unsafe int deleteBuffer(byte* buffer);
2871 #endif
2872 
2873 #if ADAPTER32BIT
2874  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2875  static private extern unsafe IntPtr create_PFCImageFile();
2876 
2877  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2878  static private extern void delete_PFCImageFile(IntPtr o);
2879 
2880  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2881  static private extern unsafe int PFCImageFile_LoadImageFile(IntPtr o, byte* filename, bool bConvertToSRGB, byte* iccFolderPath);
2882 
2883  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2884  static private extern unsafe int PFCImageFile_LoadImageFileType(IntPtr o, byte* filename, int type, bool bConvertToSRGB, byte* iccFolderPath);
2885 
2886  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2887  static private extern unsafe bool PFCImageFile_SaveImageFile(IntPtr ptr, byte* filename, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2888 
2889  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2890  static private extern unsafe bool PFCImageFile_SaveImageFileType(IntPtr ptr, byte* filename, int type, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2891 
2892  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2893  static private extern unsafe void PFCImageFile_AllocBuffer(IntPtr ptr, int width, int height, int bytes_per_pixel, int stride);
2894 
2895  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2896  static private extern unsafe int PFCImageFile_pfcImageFormat(IntPtr ptr);
2897 
2898  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2899  static private extern unsafe int PFCImageFile_exifOrientation(IntPtr ptr);
2900 
2901  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2902  static private extern unsafe byte* PFCImageFile_get_raw_image(IntPtr ptr);
2903 
2904  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2905  static private extern unsafe int PFCImageFile_get_width(IntPtr ptr);
2906 
2907  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2908  static private extern unsafe int PFCImageFile_get_height(IntPtr ptr);
2909 
2910  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2911  static private extern unsafe int PFCImageFile_get_bytes_per_pixel(IntPtr ptr);
2912 
2913  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2914  static private extern unsafe int PFCImageFile_get_stride(IntPtr ptr);
2915 
2916  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2917  static private extern unsafe bool PFCImageFile_get_sourceSRGB(IntPtr ptr);
2918 
2919  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2920  static private extern unsafe int PFCImageFile_ExpandImageBuffer(IntPtr ptr, byte* buffer, long size, int type, bool bConvertToSRGB, byte* iccFolderPath);
2921 
2922  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2923  static private extern unsafe int PFCImageFile_CompressImageBuffer(IntPtr ptr, byte** destination, int type, int jpegQuality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata);
2924 
2925  [DllImport("PFCImageFile", CallingConvention = CallingConvention.Cdecl)]
2926  static private extern unsafe int deleteBuffer(byte* buffer);
2927 #endif
2928  }
2929 }
PerfectlyClearAdapter.PFCFBPARAM.bSmooth
bool bSmooth
Set to TRUE to enable face smoothing.
Definition: PerfectlyClearAdapter.cs:495
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1683
TINTCORRECT_STRONGEST
@ TINTCORRECT_STRONGEST
Highest sensitivity level of tint detection.
Definition: PerfectlyClearPro.h:269
APPLY_ERROR_PROFILE_MISSING
@ APPLY_ERROR_PROFILE_MISSING
-1 Pointer pProfile is NULL
Definition: PerfectlyClearPro.h:394
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.rowBytes
int rowBytes
Byte width of each scanline.
Definition: PerfectlyClearAdapter.cs:713
PerfectlyClearAdapter.PFCCOREMask.angle
float angle
CW.
Definition: PerfectlyClearAdapter.cs:581
PerfectlyClearAdapter.PFCV3PARAM.lutOutput
PFC3DLutInfo lutOutput
LUT data to apply.
Definition: PerfectlyClearAdapter.cs:614
PerfectlyClearAdapter.PFCCOREMask.width
float width
radial/rounded: w of bounding rect, linear: ignored.
Definition: PerfectlyClearAdapter.cs:577
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:995
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile, PFCFEATURE feature, int ISO, string CameraModel, PFCREJECTOPTION rejectOption=PFCREJECTOPTION.PFC_REJECT_CLIPART)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:1082
PFC_CORE_MONOLITHIMAGE
@ PFC_CORE_MONOLITHIMAGE
5 Image skipped due to legacy clipart detection method
Definition: PerfectlyClearPro.h:358
PerfectlyClearAdapter.PerfectlyClear.LoadScenePresets
unsafe int LoadScenePresets(string filePath, int groupUUID=0, int *arrProfileUUID=null, int arrProfileUUIDLen=0)
Loads scene optimized presets from presets file. Engine may be AI-enabled with PFC_LoadAIEngine()....
Definition: PerfectlyClearAdapter.cs:2183
PerfectlyClearAdapter.BIASMODE
BIASMODE
Enumeration defining BIAS analysis mode.
Definition: PerfectlyClearAdapter.cs:374
PerfectlyClearAdapter.PFCFACERECT.rect
PFCRECT rect
Specifies the bounding rectangle of a face.
Definition: PerfectlyClearAdapter.cs:68
PFC_RE_FULLRES_REQUIRED
@ PFC_RE_FULLRES_REQUIRED
2 Source image (pImage) is missing
Definition: PerfectlyClearPro.h:382
PerfectlyClearAdapter.PFCFBPARAM.iEnhanceLevel
int iEnhanceLevel
Eye enhancement level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:502
PerfectlyClearAdapter.PFCFBPARAM.bLipSharpen
bool bLipSharpen
Set to TRUE to enable lip sharpening.
Definition: PerfectlyClearAdapter.cs:526
PFC_RE_CANCELLED
@ PFC_RE_CANCELLED
7 Process cancelled
Definition: PerfectlyClearPro.h:387
PFCAIFEATURE
PFCAIFEATURE
Flags defining type of model(s) to load with PFC_LoadAIEngine().
Definition: PerfectlyClearPro.h:1107
PerfectlyClearAdapter.PFCCOREPARAM.eAggressiveness
AGGRESSIVENESS eAggressiveness
The desired level of lighting for Automatic Strength Selection to target at the Exposure Correction.
Definition: PerfectlyClearAdapter.cs:460
PerfectlyClearAdapter.PerfectlyClear.Apply
unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm)
Apply correction.
Definition: PerfectlyClearAdapter.cs:1206
TINTCORRECT_AGGRESSIVE
@ TINTCORRECT_AGGRESSIVE
Aggressive detection of tint.
Definition: PerfectlyClearPro.h:266
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, string pathPreset)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1631
PerfectlyClearAdapter.PFCPARAM.mask0
PFCCOREMask mask0
masks for layer 0
Definition: PerfectlyClearAdapter.cs:668
PerfectlyClearAdapter.PFCV3PARAM.iFinishVibrancy
int iFinishVibrancy
Vibrancy correction amount.
Definition: PerfectlyClearAdapter.cs:624
CALC_FB
@ CALC_FB
Calculates for Face Beautification.
Definition: PerfectlyClearPro.h:165
HIGH_CONTRAST
@ HIGH_CONTRAST
Optimized to bring higher contrast to the image.
Definition: PerfectlyClearPro.h:275
CALC_SKINTONE
@ CALC_SKINTONE
Calculate Skintone Detection.
Definition: PerfectlyClearPro.h:175
PerfectlyClearAdapter.PFCV3PARAM.iFinishWhites
int iFinishWhites
Whites correction amount.
Definition: PerfectlyClearAdapter.cs:622
PRESET_INTELLIGENTAUTO
@ PRESET_INTELLIGENTAUTO
Intelligent Auto - this has been superceded by iAuto 2019 and is here for backwards compatability....
Definition: PerfectlyClearPro.h:186
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.Status
int Status
Definition: PerfectlyClearAdapter.cs:734
CALC_NOFAE
@ CALC_NOFAE
Skip Face Aware Exposure pre-calculations during Core pre-calculations.
Definition: PerfectlyClearPro.h:169
PFC_NR_ERRSETTINGS
@ PFC_NR_ERRSETTINGS
5 Invalid parameter
Definition: PerfectlyClearPro.h:346
PFC_PixelFormat64bppABGR
@ PFC_PixelFormat64bppABGR
Definition: PerfectlyClearPro.h:151
PerfectlyClearAdapter.PFCImageFile.LoadImage
PFC_FILE_LOAD_STATUS LoadImage(string filename, PFC_FILETYPE type, bool bConvertToSRGB=true, string iccFolderPath=null)
Load JPEG from file on disk.
Definition: PerfectlyClearAdapter.cs:2615
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor3
SELECTIVECOLOR selectiveColor3
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:484
PerfectlyClearAdapter.ADPTRRETURNCODE.SUCCESS
@ SUCCESS
Processed successfully.
PerfectlyClearAdapter.ADPTRRETURNCODE
ADPTRRETURNCODE
General return code.
Definition: PerfectlyClearAdapter.cs:385
PerfectlyClearAdapter.PFCV3PARAM.iDeltaG
int iDeltaG
Delta G correction amount.
Definition: PerfectlyClearAdapter.cs:629
PerfectlyClearAdapter.PFCImageFile.ExpandImageBuffer
PFC_FILE_LOAD_STATUS ExpandImageBuffer(MemoryStream inStream, PFC_FILETYPE type, bool bConvertToSRGB=true, string iccFolderPath=null)
Load JPEG from MemoryStream.
Definition: PerfectlyClearAdapter.cs:2738
PerfectlyClearAdapter.PFCCOREPARAM.fInfrared
float fInfrared
Scale value to control intensity of infrared correction. Range 0.0 to 1.0.
Definition: PerfectlyClearAdapter.cs:463
PerfectlyClearAdapter.SELECTIVECOLOR.S
int S
correction of S, -100 .. 100
Definition: PerfectlyClearAdapter.cs:434
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE.stride
int stride
Byte width of each scanline.
Definition: PerfectlyClearAdapter.cs:748
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:962
PerfectlyClearAdapter.DP2PARAM.fGamma
float fGamma
0.3 .. 4.0
Definition: PerfectlyClearAdapter.cs:648
PerfectlyClearAdapter.PFCV3PARAM.iDarkSkin
int iDarkSkin
Dark Skin output LUT amount.
Definition: PerfectlyClearAdapter.cs:608
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.data2
int data2
Location of Green channel.
Definition: PerfectlyClearAdapter.cs:716
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:973
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1664
PFC_CORE_NOTENABLED
@ PFC_CORE_NOTENABLED
1 Feature not enabled
Definition: PerfectlyClearPro.h:354
PerfectlyClearAdapter.PFCCOREPARAM.bDCF
bool bDCF
Set to true to enable Digital Color Fidelity. Recommended value is FALSE.
Definition: PerfectlyClearAdapter.cs:467
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClear
PerfectlyClear(string path, string licenseCode="")
Class constructor.
Definition: PerfectlyClearAdapter.cs:884
PerfectlyClearAdapter.PerfectlyClear.LoadAiEngine
int LoadAiEngine(PFCAIFEATURE aifeatures, string binPath)
Load AI models into engine. Takes time and memory.
Definition: PerfectlyClearAdapter.cs:2149
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.pSFBParam
void * pSFBParam
Internal use only.
Definition: PerfectlyClearAdapter.cs:726
APPLY_SUCCESS
@ APPLY_SUCCESS
0 Success.
Definition: PerfectlyClearPro.h:393
PerfectlyClearAdapter.PFCPARAM.layer0
PFCV3PARAM layer0
params on layers 0 - top/inside
Definition: PerfectlyClearAdapter.cs:665
PerfectlyClearAdapter.PFCPOINT.x
int x
x coordinate of this point.
Definition: PerfectlyClearAdapter.cs:21
PerfectlyClearAdapter.PFCFBPARAM.iSlim
int iSlim
Face slimming level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:510
PerfectlyClearAdapter.DCFMODE.FIDELITY_VIVID
@ FIDELITY_VIVID
For more color vibrancy.
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer
Struct defining an image.
Definition: PerfectlyClearAdapter.cs:710
PFC_FB_SUCCESS
@ PFC_FB_SUCCESS
0 Success
Definition: PerfectlyClearPro.h:365
PerfectlyClearAdapter.PFCFBPARAM.bBlemish
bool bBlemish
Set to TRUE to enable blemish removal.
Definition: PerfectlyClearAdapter.cs:507
APPLY_BADFORMAT
@ APPLY_BADFORMAT
-5 Pixel format not supported
Definition: PerfectlyClearPro.h:398
PerfectlyClearAdapter.PFCImageFile.PFCImageFile
PFCImageFile()
Constructs empty PFCImageFile, to be filled with LoadImageFile()
Definition: PerfectlyClearAdapter.cs:2530
LIPSHARPENTYPE_FINE
@ LIPSHARPENTYPE_FINE
Fine touch of sharpening.
Definition: PerfectlyClearPro.h:333
PerfectlyClearAdapter.PFCPARAM.core
PFCCOREPARAM core
Core corrections to apply.
Definition: PerfectlyClearAdapter.cs:660
PerfectlyClearAdapter.PFCCOREMask.height
float height
radial/rounded: h of bounding rect, linear: dist from centerY where grad becomes 1....
Definition: PerfectlyClearAdapter.cs:578
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.height
int height
Pixel height of image.
Definition: PerfectlyClearAdapter.cs:712
PFC_CORE_CANCELLED
@ PFC_CORE_CANCELLED
2 Process cancelled
Definition: PerfectlyClearPro.h:355
PRESET_BEAUTIFYPLUS
@ PRESET_BEAUTIFYPLUS
Beautify Plus provides stronger beautification corrections. This is in the 'Perfectly Clear Essential...
Definition: PerfectlyClearPro.h:183
PerfectlyClearAdapter.PFCFBFACEINFO1.leftEye
PFCPOINT leftEye
Point of left eye in detected face.
Definition: PerfectlyClearAdapter.cs:38
PerfectlyClearAdapter.PFCPARAM.mask2
PFCCOREMask mask2
masks for layer 2
Definition: PerfectlyClearAdapter.cs:670
PRESET_DETAILS
@ PRESET_DETAILS
iAuto Details - legacy preset for backwards compability. This is in the 'Athentech Legacy' group in E...
Definition: PerfectlyClearPro.h:184
PFC_FB_NOT_AVAILABLE
@ PFC_FB_NOT_AVAILABLE
10 Face beautification feature not available
Definition: PerfectlyClearPro.h:375
PerfectlyClearAdapter.PFCV3PARAM.iDeltaR
int iDeltaR
Delta R correction amount.
Definition: PerfectlyClearAdapter.cs:628
PerfectlyClearAdapter.PFCCOREPARAM.iSplitColorCold
int iSplitColorCold
Enhance cold tones.
Definition: PerfectlyClearAdapter.cs:479
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1367
APPLY_WASM_INVALID_CERTIFICATE
@ APPLY_WASM_INVALID_CERTIFICATE
-9 WASM certificate invalid or not matching APIKEY and domain
Definition: PerfectlyClearPro.h:402
SKINSMOOTHTYPE_SUBTLE
@ SKINSMOOTHTYPE_SUBTLE
The subtle correction removes the wrinkles and spots alone while it keeps the texture of the face unc...
Definition: PerfectlyClearPro.h:315
PerfectlyClearAdapter.PFCCOREPARAM.bLightDiffusion
bool bLightDiffusion
Set to true to enable light diffusion during DCF correction.
Definition: PerfectlyClearAdapter.cs:464
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE.data
void * data
Pointer pointing to the first byte of image data buffer.
Definition: PerfectlyClearAdapter.cs:750
PerfectlyClearAdapter.DP2PARAM.iDeltaG
int iDeltaG
-100 .. 100
Definition: PerfectlyClearAdapter.cs:646
PFCFACERECT
struct PFCFaceRect PFCFACERECT
Structure defining face attributes detected by the Face Detection library.
PFC_CORE_INSUFFICIENTMEMORY
@ PFC_CORE_INSUFFICIENTMEMORY
4 Process aborted because of insufficient memory
Definition: PerfectlyClearPro.h:357
PerfectlyClearAdapter.PFCCOREPARAM.iSplitColorWarm
int iSplitColorWarm
Enhance warm tones.
Definition: PerfectlyClearAdapter.cs:478
APPLY_WASM_INVALID_APIKEY
@ APPLY_WASM_INVALID_APIKEY
-8 Wrong APIKEY for WASM certificate
Definition: PerfectlyClearPro.h:401
PerfectlyClearAdapter.PFCPIXELFORMAT
PFCPIXELFORMAT
defines the format of the image data
Definition: PerfectlyClearAdapter.cs:128
SKINTONINGTYPE_WHITE
@ SKINTONINGTYPE_WHITE
Whitens (bleaches) face. Recommended mainly for darker skin.
Definition: PerfectlyClearPro.h:323
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.data3
int data3
Location of Blue channel.
Definition: PerfectlyClearAdapter.cs:717
SKINSMOOTHTYPE_DEFAULT
@ SKINSMOOTHTYPE_DEFAULT
This type of correction provides a more uniform appearance to the complexion. It combines the natural...
Definition: PerfectlyClearPro.h:316
PFC_PixelFormat32bppARGB
@ PFC_PixelFormat32bppARGB
Definition: PerfectlyClearPro.h:123
PerfectlyClearAdapter.PFCPARAM
Struct PFCPARAM the master structure of all processing parameters.
Definition: PerfectlyClearAdapter.cs:659
PerfectlyClearAdapter.PFCImageFile.SaveImageFile
bool SaveImageFile(string filename, PFC_FILETYPE type, int jpegQuality=92, bool bConvertToOriginalColorSpace=true, bool bEmbedOriginalMetadata=true)
Write image data to file*.
Definition: PerfectlyClearAdapter.cs:2669
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE.height
int height
Pixel height of image.
Definition: PerfectlyClearAdapter.cs:747
PerfectlyClearAdapter.PerfectlyClear.SetProtectionPath
static int SetProtectionPath(string path, string licenseCode)
Set path to location of SDK License files This enables license protection and allows activation using...
Definition: PerfectlyClearAdapter.cs:796
PerfectlyClearAdapter.PFCFBPARAM.bEnlarge
bool bEnlarge
Set to TRUE to enable eye enlargement.
Definition: PerfectlyClearAdapter.cs:499
PerfectlyClearAdapter.PerfectlyClear.ReadImage
Bitmap ReadImage(string filename)
Utility function for reading image file into Bitmap.
Definition: PerfectlyClearAdapter.cs:2026
PFC_FB_NO_CORRECTION
@ PFC_FB_NO_CORRECTION
8 No correction occur during process
Definition: PerfectlyClearPro.h:373
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref PFCImageFile imgfile, PFCFEATURE feature)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:984
PerfectlyClearAdapter.PFCV3PARAM.iFinishTemp
int iFinishTemp
Temp correction amount.
Definition: PerfectlyClearAdapter.cs:616
PerfectlyClearAdapter.PerfectlyClear.SetParam
void SetParam(PFCPRESETID id)
Set process parameters in current instance.
Definition: PerfectlyClearAdapter.cs:1736
PerfectlyClearAdapter.PFCCOREMask.invert
bool invert
invert mask (x = 1.0 - x). NOTE: UI meaning of invert is: if one mask layer set invert = true....
Definition: PerfectlyClearAdapter.cs:584
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE.format
PFCPIXELFORMAT format
Defines byte order of input buffer.
Definition: PerfectlyClearAdapter.cs:749
PerfectlyClearAdapter.PFCPARAM.v3
PFCV3PARAM v3
V3 Corrections.
Definition: PerfectlyClearAdapter.cs:664
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.CORE_Status
PFCCORE_STATUS CORE_Status
Status code for CORE pre-calc analysis.
Definition: PerfectlyClearAdapter.cs:729
PerfectlyClearAdapter.PFCCOREMask.centerX
float centerX
X of center.
Definition: PerfectlyClearAdapter.cs:575
PerfectlyClearAdapter.PFCV3PARAM.iFinishExposure
int iFinishExposure
Exposure correction amount.
Definition: PerfectlyClearAdapter.cs:618
PerfectlyClearAdapter.PFCAPPLYSTATUS
PFCAPPLYSTATUS
Enumeration defining return code from the Apply() function.
Definition: PerfectlyClearAdapter.cs:325
PFCPARAM
Struct PFCPARAM the master structure of all processing parameters.
Definition: PerfectlyClearPro.h:640
PFC_RE_INVALID_PARAMETER
@ PFC_RE_INVALID_PARAMETER
5 Invalid parameter
Definition: PerfectlyClearPro.h:385
PerfectlyClearAdapter.PFCCOREPARAM.fTintScale
float fTintScale
Scalar value of how much tint correction should be applied. Range 0.0 to 1.0.
Definition: PerfectlyClearAdapter.cs:444
PerfectlyClearAdapter.PFCCOREMask.radius
float radius
only for MASK_ROUNDRECT - corner radius, relative to image w.
Definition: PerfectlyClearAdapter.cs:579
PerfectlyClearAdapter.PFCCOREPARAM.iSkintoneStrengthExposure
int iSkintoneStrengthExposure
Strength of exposure bias -50 .. 50 applied with input skintone correction.
Definition: PerfectlyClearAdapter.cs:475
PFC_RE_NOT_FOUND
@ PFC_RE_NOT_FOUND
3 Red eye not found
Definition: PerfectlyClearPro.h:383
PerfectlyClearAdapter.AGGRESSIVENESS.AGGRESSIVE
@ AGGRESSIVE
More aggressive in exposure correction.
AI_CORRECTIONS
@ AI_CORRECTIONS
Loads AI-based corrections model, requiring the file dynamic.pnn
Definition: PerfectlyClearPro.h:1109
PerfectlyClearAdapter.PFCAIFEATURE
PFCAIFEATURE
Flags defining type of model(s) to load with PFC_LoadAIEngine().
Definition: PerfectlyClearAdapter.cs:117
PerfectlyClearAdapter.PerfectlyClear.PFCENGINE.status
uint status
Status of engine defined in PFCENGINESTATUS. For NO-SFB version the status will always be ENGINESTATU...
Definition: PerfectlyClearAdapter.cs:706
PerfectlyClearAdapter.PFCCOREPARAM.bSkintoneAuto
bool bSkintoneAuto
if TRUE iSkintoneType is detected, StrengthLut|StrengthExposure are obtained from PFC_GetAutoSkintone...
Definition: PerfectlyClearAdapter.cs:476
CALC_AICOLOR
@ CALC_AICOLOR
Calculate Auto WB params.
Definition: PerfectlyClearPro.h:176
PerfectlyClearAdapter.SELECTIVECOLOR.p
int p
end of Hue range ramp
Definition: PerfectlyClearAdapter.cs:432
PerfectlyClearAdapter.PFCCOREPARAM.iSkintoneType
int iSkintoneType
Skintone type, pale to dark, 1 .. 10 defines type of input skintone correction.
Definition: PerfectlyClearAdapter.cs:473
PerfectlyClearAdapter.PFCFBPARAM.iEyeCirc
int iEyeCirc
Eye circle removal level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:504
PRESET_IAUTO_21_ASIA
@ PRESET_IAUTO_21_ASIA
Based on iAuto 21, but with brighter Skin & Depth Bias for truer skin tone.
Definition: PerfectlyClearPro.h:190
PerfectlyClearAdapter.PFCFBFACEINFO1.face
PFCRECT face
Bounding rectangle of detected face.
Definition: PerfectlyClearAdapter.cs:40
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1345
PerfectlyClearAdapter.PerfectlyClear.ReadPresets
int ReadPresets(string path)
Read a preset from .preset file.
Definition: PerfectlyClearAdapter.cs:1760
SKINMODE_BODY
@ SKINMODE_BODY
Apply correction on most skin regions regardless they are linked with a face or not.
Definition: PerfectlyClearPro.h:309
CALC_ALL
@ CALC_ALL
Calculates for all classic features, all of the above.
Definition: PerfectlyClearPro.h:167
PerfectlyClearAdapter.PFCFBPARAM.bBlush
bool bBlush
Set to TRUE to add blush.
Definition: PerfectlyClearAdapter.cs:529
PRESET_IAUTO_PEOPLE
@ PRESET_IAUTO_PEOPLE
New default preset for 2023 - same corrections as iAuto People from the Universal AI Preset Selection...
Definition: PerfectlyClearPro.h:191
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.FB_Status
PFCFB_STATUS FB_Status
Status code for Face Beautification pre-calc analysis.
Definition: PerfectlyClearAdapter.cs:731
PerfectlyClearAdapter.DP2PARAM.bAuto
bool bAuto
if true use ai-detected params instead
Definition: PerfectlyClearAdapter.cs:652
PFCPRESETID
PFCPRESETID
ENUM for presets support by this SDK.
Definition: PerfectlyClearPro.h:180
PerfectlyClearAdapter.PFCV3PARAM.iColorVibrancy
int iColorVibrancy
Color Vibrancy amount.
Definition: PerfectlyClearAdapter.cs:607
PerfectlyClearAdapter.PFCREPARAM.bEnabled
bool bEnabled
Set to TRUE to enable red eye removal.
Definition: PerfectlyClearAdapter.cs:554
PerfectlyClearAdapter.PFCCOREPARAM.iSkintoneAutoStrength
int iSkintoneAutoStrength
If bSkintonAuto is TRUE defines percents of iSkintoneStrengthLut iSkintoneStrengthExposure to apply,...
Definition: PerfectlyClearAdapter.cs:477
CALC_RE
@ CALC_RE
Calculates for Red Eye Removal.
Definition: PerfectlyClearPro.h:166
PerfectlyClearAdapter.AGGRESSIVENESS
AGGRESSIVENESS
Enumeration defining different Auto Exposure calculation modes.
Definition: PerfectlyClearAdapter.cs:352
PerfectlyClearAdapter.SKINMODE
SKINMODE
Enumeration defining modes in Perfect Smooth analysis.
Definition: PerfectlyClearAdapter.cs:394
PerfectlyClearAdapter.PFCImageFile.LoadImage
PFC_FILE_LOAD_STATUS LoadImage(string filename, bool bConvertToSRGB=false, string iccFolderPath=null)
Load JPEG from file on disk.
Definition: PerfectlyClearAdapter.cs:2584
PerfectlyClearAdapter.PFCFBPARAM.iCatchLight
int iCatchLight
Catchlight level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:514
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE.width
int width
Pixel width of image.
Definition: PerfectlyClearAdapter.cs:746
APPLY_WASM_CERTIFICATE_WRONG_VERSION
@ APPLY_WASM_CERTIFICATE_WRONG_VERSION
-11 Wrong format version of WASM certificate
Definition: PerfectlyClearPro.h:404
PFC_NR_CANCELLED
@ PFC_NR_CANCELLED
3 Process cancelled
Definition: PerfectlyClearPro.h:344
PerfectlyClearAdapter.PFCCOREPARAM.bLocalContrast
bool bLocalContrast
Set to true to enable Local Contrast.
Definition: PerfectlyClearAdapter.cs:471
PerfectlyClearAdapter.PFCFBFACEINFO1.rightEye
PFCPOINT rightEye
Point of right eye in detected face.
Definition: PerfectlyClearAdapter.cs:39
PerfectlyClearAdapter.DP2PARAM.mode
int mode
reserved unused
Definition: PerfectlyClearAdapter.cs:651
PerfectlyClearAdapter.PFCNRPARAM.iDetailOffset
int iDetailOffset
Offset to recommended level of preservation of details. Range -30 to 30.
Definition: PerfectlyClearAdapter.cs:548
PerfectlyClearAdapter.PFCV3PARAM.lutInputFoliageGreen
PFC3DLutInfo lutInputFoliageGreen
LUT data to apply.
Definition: PerfectlyClearAdapter.cs:611
PFC_NR_FULLRES_REQUIRED
@ PFC_NR_FULLRES_REQUIRED
2 Source image (pImage) is missing
Definition: PerfectlyClearPro.h:343
PerfectlyClearAdapter.PFCRECT.top
int top
y in point corrdinate of this rect.
Definition: PerfectlyClearAdapter.cs:30
PerfectlyClearAdapter.PFCCOREPARAM.bUseFAE
bool bUseFAE
Set to true (recommended) to enable Face Aware Exposure selection. Recommended exposure will be calcu...
Definition: PerfectlyClearAdapter.cs:459
PerfectlyClearAdapter.PFCFBPARAM.iEnlargeLevel
int iEnlargeLevel
Eye enlargement level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:500
PFCAPPLYSTATUS
PFCAPPLYSTATUS
Enumeration defining return code from the Apply() function.
Definition: PerfectlyClearPro.h:392
PerfectlyClearAdapter.PFCV3PARAM.iNeutralDensity
int iNeutralDensity
Neutral density filter amout.
Definition: PerfectlyClearAdapter.cs:606
PerfectlyClearAdapter.PFCV3PARAM.lutInputFoliageBrown
PFC3DLutInfo lutInputFoliageBrown
LUT data to apply.
Definition: PerfectlyClearAdapter.cs:612
PerfectlyClearAdapter.PFCFBPARAM.bEnabled
bool bEnabled
Set to TRUE to enable entire face beautification.
Definition: PerfectlyClearAdapter.cs:494
PerfectlyClearAdapter.PFCImageFile.PFC_FILE_LOAD_STATUS
PFC_FILE_LOAD_STATUS
Return status after loading a file with PFCImageFile.
Definition: PerfectlyClearAdapter.cs:2563
PFC_CORE_NOSOURCEIMAGE
@ PFC_CORE_NOSOURCEIMAGE
3 Source image (pImage) is missing
Definition: PerfectlyClearPro.h:356
PFCIMAGEPROFILE
Struct defining an image profile as calculated from PFC_Calc() function.
Definition: PerfectlyClearPro.h:654
PerfectlyClearAdapter.DP2PARAM.iDeltaR
int iDeltaR
-100 .. 100
Definition: PerfectlyClearAdapter.cs:645
PerfectlyClearAdapter.PFCNR_STATUS
PFCNR_STATUS
Enumeration defining status of Noise Removal pre-calculation.
Definition: PerfectlyClearAdapter.cs:261
PFC_RE_NOTENABLED
@ PFC_RE_NOTENABLED
1 Feature not enabled
Definition: PerfectlyClearPro.h:381
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm)
Performs precalc analysis.
Definition: PerfectlyClearAdapter.cs:952
PerfectlyClearAdapter.SELECTIVECOLOR
Struct defining selective color correction.
Definition: PerfectlyClearAdapter.cs:428
PerfectlyClearAdapter.PFCPOINT.y
int y
y coordinate of this point.
Definition: PerfectlyClearAdapter.cs:22
PFC_NR_SUCCESS
@ PFC_NR_SUCCESS
0 Success
Definition: PerfectlyClearPro.h:341
PerfectlyClearAdapter.DCFMODE
DCFMODE
Enumeration defining DCF analysis mode.
Definition: PerfectlyClearAdapter.cs:360
LOAD_FAILED_CONVERT_SRGB
@ LOAD_FAILED_CONVERT_SRGB
Error: failed to convert to sRGB.
Definition: PFCImageFile.h:26
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref PFCImageFile imgfile, int ISO, string CameraModel, bool bFastFAE)
Performs auto correction.
Definition: PerfectlyClearAdapter.cs:1464
PerfectlyClearAdapter.PFCFACERECT.childLevel
int childLevel
We don't implement this.
Definition: PerfectlyClearAdapter.cs:78
PFC_REJECT_MONOLITH
@ PFC_REJECT_MONOLITH
Reject simple images that don't benefit from correction, like solid colors. This was the default befo...
Definition: PerfectlyClearPro.h:413
PFC_PixelFormat24bppRGB
@ PFC_PixelFormat24bppRGB
Definition: PerfectlyClearPro.h:52
PRESET_IAUTO_2019
@ PRESET_IAUTO_2019
iAuto for even better image corrections
Definition: PerfectlyClearPro.h:187
APPLY_CANCELLED
@ APPLY_CANCELLED
-3 Operation cancelled
Definition: PerfectlyClearPro.h:396
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.width
int width
Pixel width of image.
Definition: PerfectlyClearAdapter.cs:711
PerfectlyClearAdapter.PFCV3PARAM.bDynamic
bool bDynamic
Enable Dynamic correction.
Definition: PerfectlyClearAdapter.cs:632
PerfectlyClearAdapter.DP2PARAM
Struct describing V3 parameters.
Definition: PerfectlyClearAdapter.cs:643
PerfectlyClearAdapter.PFCCOREMask
Struct for core mask.
Definition: PerfectlyClearAdapter.cs:573
LIPSHARPENTYPE_COARSE
@ LIPSHARPENTYPE_COARSE
Lip details are coarsely pronounced.
Definition: PerfectlyClearPro.h:335
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.pInternal
void * pInternal
Internal use only.
Definition: PerfectlyClearAdapter.cs:727
PerfectlyClearAdapter.PFCFBPARAM.bTeeth
bool bTeeth
Set to TRUE to enable teeth whitening.
Definition: PerfectlyClearAdapter.cs:505
PerfectlyClearAdapter.PFCCOREPARAM.bContrast
bool bContrast
Set to TRUE to also apply Athentech's patented Medical Imaging contrast technology.
Definition: PerfectlyClearAdapter.cs:449
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.NR_Status
PFCNR_STATUS NR_Status
Status code for Noise Removal pre-calc analysis.
Definition: PerfectlyClearAdapter.cs:730
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.pRedEyeParam
void * pRedEyeParam
Internal use only.
Definition: PerfectlyClearAdapter.cs:725
PerfectlyClearAdapter.DCFMODE.FIDELITY_STANDARD
@ FIDELITY_STANDARD
For normal photo.
PerfectlyClearAdapter.PFCCOREPARAM.iContrast
int iContrast
Intensity of contrast or depth. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:451
PerfectlyClearAdapter.DP2PARAM.iDensity
int iDensity
-100 .. 100 // Same meaning as DP2 Adjust params
Definition: PerfectlyClearAdapter.cs:644
CALC_COMPOSITE
@ CALC_COMPOSITE
Calculate Composite Detection.
Definition: PerfectlyClearPro.h:174
PerfectlyClearAdapter.PFCPARAM.re
PFCREPARAM re
Red Eye Removal.
Definition: PerfectlyClearAdapter.cs:663
PerfectlyClearAdapter.AGGRESSIVENESS.MODERATE
@ MODERATE
Moderate level of exposure correction.
PerfectlyClearAdapter.PFCREPARAM
Structure encapsulating Red Eye Correction parameters.
Definition: PerfectlyClearAdapter.cs:553
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClear
PerfectlyClear()
Special class constructor for multithreading.
Definition: PerfectlyClearAdapter.cs:846
PerfectlyClearAdapter.SELECTIVECOLOR.m
int m
end of flat part of Hue range
Definition: PerfectlyClearAdapter.cs:431
PerfectlyClearAdapter.PFCCOREPARAM.eContrastMode
CONTRASTMODE eContrastMode
Select contrast mode.
Definition: PerfectlyClearAdapter.cs:450
PerfectlyClearAdapter.PFCFACERECT.yawAngle
int yawAngle
The Yaw or profile angle, from -90 (left profile) to 90 (right profile)
Definition: PerfectlyClearAdapter.cs:81
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.pPfcParam
void * pPfcParam
Internal use only.
Definition: PerfectlyClearAdapter.cs:723
PerfectlyClearAdapter.PFCCOREPARAM.iLocalContrast
int iLocalContrast
Amount of Local Contrast to apply. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:470
PerfectlyClearAdapter.PFCFACERECT.widthImage
int widthImage
image width
Definition: PerfectlyClearAdapter.cs:85
PFC_CORE_SUCCESS
@ PFC_CORE_SUCCESS
0 Success
Definition: PerfectlyClearPro.h:353
PerfectlyClearAdapter.PFCV3PARAM.lutInputSky
PFC3DLutInfo lutInputSky
LUT data to apply.
Definition: PerfectlyClearAdapter.cs:610
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor0
SELECTIVECOLOR selectiveColor0
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:481
PFC_NR_NOTFOUND
@ PFC_NR_NOTFOUND
7 Noise not found
Definition: PerfectlyClearPro.h:348
PerfectlyClearAdapter.PerfectlyClear.HasFaceBeautification
bool HasFaceBeautification()
Query if Face Beautification feature is available.
Definition: PerfectlyClearAdapter.cs:1862
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE
Struct defining an image profile as calculated from PFC_Calc() function.
Definition: PerfectlyClearAdapter.cs:722
PerfectlyClearAdapter.PFCCOREPARAM.bVibrancy
bool bVibrancy
Set to true (recommended default) to enable Color Vibrancy in the library.
Definition: PerfectlyClearAdapter.cs:446
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.data1
int data1
Location of Red channel.
Definition: PerfectlyClearAdapter.cs:715
LOAD_ERROR
@ LOAD_ERROR
Error.
Definition: PFCImageFile.h:24
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.pNoiseParam
void * pNoiseParam
Internal use only.
Definition: PerfectlyClearAdapter.cs:724
PerfectlyClearAdapter.PFCFACERECT.smileLevel
int smileLevel
Indicates the presence of a smile.
Definition: PerfectlyClearAdapter.cs:80
PFCSCENEDESCRIPTION
Scene description.
Definition: PerfectlyClearPro.h:1231
PerfectlyClearAdapter.PFCFBPARAM.iSmoothLevel
int iSmoothLevel
Face smoothing level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:496
PerfectlyClearAdapter.PFCFEATURE
PFCFEATURE
ENUM controlling types of calculations at the pre-calculation stage.
Definition: PerfectlyClearAdapter.cs:97
PerfectlyClearAdapter.PFCCOREPARAM.bDynamicRange
bool bDynamicRange
Set to TRUE to enable dynamic range correction.
Definition: PerfectlyClearAdapter.cs:466
PerfectlyClearAdapter.PFCCOREPARAM.bUseAutomaticStrengthSelection
bool bUseAutomaticStrengthSelection
Set to TRUE (recommended default) to enable Automatic Strength Selection. Perfectly Clear will determ...
Definition: PerfectlyClearAdapter.cs:458
PerfectlyClearAdapter.PFCNRPARAM.iPreset
int iPreset
Definition: PerfectlyClearAdapter.cs:539
PerfectlyClearAdapter.PFCRECT.height
int height
height of this rect.
Definition: PerfectlyClearAdapter.cs:32
PerfectlyClearAdapter.PFCCOREPARAM.iMinStrength
int iMinStrength
Use this to set the min recommended exposure correction.
Definition: PerfectlyClearAdapter.cs:472
PerfectlyClearAdapter.PFCFBPARAM.iCatchLightMode
int iCatchLightMode
Definition: PerfectlyClearAdapter.cs:515
PFC_PixelFormat24bppBGR
@ PFC_PixelFormat24bppBGR
Definition: PerfectlyClearPro.h:65
PerfectlyClearAdapter.PFCImageFile.SaveImageFile
bool SaveImageFile(string filename, int jpegQuality=92, bool bConvertToOriginalColorSpace=true, bool bEmbedOriginalMetadata=true)
Write image data to file*.
Definition: PerfectlyClearAdapter.cs:2645
AI_SKINTONE
@ AI_SKINTONE
Loads skintone detection model. This is enabled automatically when using AI_SCENE_DETECTION.
Definition: PerfectlyClearPro.h:1111
PerfectlyClearAdapter.DP2PARAM.iSaturation
int iSaturation
-100 .. 100
Definition: PerfectlyClearAdapter.cs:650
PFCIMAGE
Struct defining an image to be used in PFC library.
Definition: PerfectlyClearPro.h:256
PerfectlyClearAdapter.PFCCOREPARAM.bHighlightPreservation
bool bHighlightPreservation
Set to true to enable Highlight Preservation.
Definition: PerfectlyClearAdapter.cs:455
BIAS_BRIGHTER_PREFERENCE
@ BIAS_BRIGHTER_PREFERENCE
Average usage with brighter tone, corresponds to "Bright" in PfC Products.
Definition: PerfectlyClearPro.h:300
PerfectlyClearAdapter.PFCFBPARAM.bEnhance
bool bEnhance
Set to TRUE to enable eye enhancement.
Definition: PerfectlyClearAdapter.cs:501
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor5
SELECTIVECOLOR selectiveColor5
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:486
PFC_NR_ERRBITMAP
@ PFC_NR_ERRBITMAP
4 Error reading image data
Definition: PerfectlyClearPro.h:345
PerfectlyClearAdapter.SELECTIVECOLOR.L
int L
correction of L, -100 .. 100
Definition: PerfectlyClearAdapter.cs:435
PerfectlyClearAdapter.PFCRECT.left
int left
x in point coordinate of this rect.
Definition: PerfectlyClearAdapter.cs:29
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor1
SELECTIVECOLOR selectiveColor1
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:482
PerfectlyClearAdapter.PerfectlyClear.PerfectlyClearImageTransfer.columnBytes
int columnBytes
Byte width of one pixel.
Definition: PerfectlyClearAdapter.cs:714
PFCENGINE
Struct defining an PFC engine instance.
Definition: PerfectlyClearPro.h:250
PerfectlyClearAdapter.PFCFACERECT.angle
int angle
Roll angle of the face, from -179 to 180 degrees. 0 degrees means the face it oriented "normally",...
Definition: PerfectlyClearAdapter.cs:74
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor6
SELECTIVECOLOR selectiveColor6
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:487
PerfectlyClearAdapter.PFCV3PARAM.iFinishHighlights
int iFinishHighlights
Highlights correction amount.
Definition: PerfectlyClearAdapter.cs:621
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref PFCImageFile imgfile, string pathPreset)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1647
PerfectlyClearAdapter.PFCPARAM.fb
PFCFBPARAM fb
Face Beautification corrections.
Definition: PerfectlyClearAdapter.cs:661
PerfectlyClearAdapter.PFCCOREPARAM.fBiasScale
float fBiasScale
Scalar value of how much BIAS correction should be applied. Range 0.0 to 1.0.
Definition: PerfectlyClearAdapter.cs:453
PerfectlyClearAdapter.SELECTIVECOLOR.H
int H
shift of Hue, -180 .. 180
Definition: PerfectlyClearAdapter.cs:433
PerfectlyClearAdapter.PerfectlyClear.FBFaceCount
int FBFaceCount()
Get number of faces.
Definition: PerfectlyClearAdapter.cs:1872
SKINMODE_FACE
@ SKINMODE_FACE
Apply correction ONLY on skin regions included in faces.
Definition: PerfectlyClearPro.h:308
PerfectlyClearAdapter.PFCCOREPARAM.iStrength
int iStrength
Set the strength of exposure correction. If Automatic Strength Selection is enabled,...
Definition: PerfectlyClearAdapter.cs:448
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGE
Struct defining an image to be used in PFC library.
Definition: PerfectlyClearAdapter.cs:745
PerfectlyClearAdapter.PFCFB_STATUS
PFCFB_STATUS
Enumeration defining status of Face Beautification pre-calculation.
Definition: PerfectlyClearAdapter.cs:295
PerfectlyClearAdapter.PFCV3PARAM.iOutLUTsaturation
int iOutLUTsaturation
lutOutput saturation -100 .. 100
Definition: PerfectlyClearAdapter.cs:637
BIAS_NONE
@ BIAS_NONE
Turn off bias correction.
Definition: PerfectlyClearPro.h:297
TINTCORRECT_DEFAULT
@ TINTCORRECT_DEFAULT
Moderate level of tint detection.
Definition: PerfectlyClearPro.h:267
PerfectlyClearAdapter.PerfectlyClear.PFCENGINE.pEngine
void * pEngine
Pointer to binary definition of the processing engine.
Definition: PerfectlyClearAdapter.cs:705
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref PFCImageFile imgfile, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1702
PerfectlyClearAdapter.PFCFBPARAM.iBlemish
int iBlemish
Blemish removal level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:508
PerfectlyClearAdapter.PFCREJECTOPTION
PFCREJECTOPTION
Enumeration defining reject options.
Definition: PerfectlyClearAdapter.cs:287
PerfectlyClearAdapter.PFCFBPARAM.eSkinToningMode
SKINMODE eSkinToningMode
Use SKINMODE_FACE to apply correction ONLY on skin regions included in faces. Use SKINMODE_BODY to ap...
Definition: PerfectlyClearAdapter.cs:524
PerfectlyClearAdapter.PerfectlyClear.GetSceneDescription
bool GetSceneDescription(int index, ref PFCSCENEDESCRIPTION sceneDescription)
Get the scene description for the given index number Requires an initialized ai engine.
Definition: PerfectlyClearAdapter.cs:2261
SKINSMOOTHTYPE_SUPERSMOOTH
@ SKINSMOOTHTYPE_SUPERSMOOTH
This is a more aggressive and effective correction where the appearance of the entire skin (including...
Definition: PerfectlyClearPro.h:317
PFC_FB_FULLRES_REQUIRED
@ PFC_FB_FULLRES_REQUIRED
3 Source image (pImage) is missing
Definition: PerfectlyClearPro.h:368
PFC_REJECT_CLIPART
@ PFC_REJECT_CLIPART
Reject images classified as clipart, used by default.
Definition: PerfectlyClearPro.h:414
PerfectlyClearAdapter.DP2PARAM.bEnable
bool bEnable
enables overall correction
Definition: PerfectlyClearAdapter.cs:653
PerfectlyClearAdapter.PFCV3PARAM
Struct describing V3 parameters.
Definition: PerfectlyClearAdapter.cs:600
PerfectlyClearAdapter.PerfectlyClear.ReleaseProtectionPath
static void ReleaseProtectionPath()
Releases resources from SetProtectionPath.
Definition: PerfectlyClearAdapter.cs:835
PerfectlyClearAdapter.PFCPRESETID
PFCPRESETID
ENUM for presets support by this SDK.
Definition: PerfectlyClearAdapter.cs:245
PerfectlyClearAdapter.PFCPARAM.mask1
PFCCOREMask mask1
masks for layer 1
Definition: PerfectlyClearAdapter.cs:669
PerfectlyClearAdapter.PFCFACERECT.blinkLevelL
int blinkLevelL
Left eye Blink level.
Definition: PerfectlyClearAdapter.cs:76
PerfectlyClearAdapter.PFCFBPARAM.iDeFlash
int iDeFlash
Deflash level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:512
PerfectlyClearAdapter.PFCFBFACEINFO
Class defining face area detected from the SFB library.
Definition: PerfectlyClearAdapter.cs:45
AI_SCENE_DETECTION
@ AI_SCENE_DETECTION
Loads scene detection model, requiring one or two pnn files with filenames like pro_and_universal_202...
Definition: PerfectlyClearPro.h:1108
PFC_PixelFormat48bppRGB
@ PFC_PixelFormat48bppRGB
Definition: PerfectlyClearPro.h:93
PerfectlyClearAdapter.PFCCOREPARAM.fLightDiffusion
float fLightDiffusion
Scale value to control intensity of light diffusion correction.
Definition: PerfectlyClearAdapter.cs:465
PerfectlyClearAdapter.PFCFBPARAM.colorSkinToning
uint colorSkinToning
Skin Toning color AARRGGBB default 0xFFF5BCA9 ({245, 188, 169})
Definition: PerfectlyClearAdapter.cs:531
CALC_CORE
@ CALC_CORE
Calculates for Perfectly Clear Core correction.
Definition: PerfectlyClearPro.h:163
PerfectlyClearAdapter.PFCV3PARAM.iPreprocessEV
int iPreprocessEV
EV correction amount (Image Ambulace)
Definition: PerfectlyClearAdapter.cs:604
PFC_PixelFormat48bppBGR
@ PFC_PixelFormat48bppBGR
Definition: PerfectlyClearPro.h:136
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1549
PerfectlyClearAdapter.PFCFACERECT.blinkLevelR
int blinkLevelR
Right eye Blink level.
Definition: PerfectlyClearAdapter.cs:77
PerfectlyClearAdapter.PFCCOREPARAM.bSharpen
bool bSharpen
Set to true to enable sharpening.
Definition: PerfectlyClearAdapter.cs:456
PerfectlyClearAdapter.PerfectlyClear.Apply
unsafe PFCAPPLYSTATUS Apply(ref Bitmap bm, int iOpacity)
Apply correction.
Definition: PerfectlyClearAdapter.cs:1227
PerfectlyClearAdapter.PFCFBPARAM.eSmoothMode
SKINMODE eSmoothMode
Use SKINMODE_FACE to apply correction ONLY on skin regions included in faces. Use SKINMODE_BODY to ap...
Definition: PerfectlyClearAdapter.cs:497
PerfectlyClearAdapter.PFC3DLutInfo
Struct describing 3D Lut information.
Definition: PerfectlyClearAdapter.cs:590
TINTCORRECTION
TINTCORRECTION
Enumeration defining different abnormal tint analysis mode.
Definition: PerfectlyClearPro.h:265
PerfectlyClearAdapter.PFCFBFACEINFO.leftEye
PFCPOINT leftEye
Point of left eye in detected face.
Definition: PerfectlyClearAdapter.cs:46
PerfectlyClearAdapter.PFCCOREPARAM.bInfrared
bool bInfrared
Set to true (recommended default) to enable infrared correction. It's a good idea to turn Infrared Co...
Definition: PerfectlyClearAdapter.cs:462
PerfectlyClearAdapter.PFCFBPARAM.iTeethLevel
int iTeethLevel
Teeth whitening level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:506
PerfectlyClearAdapter.SELECTIVECOLOR.a
int a
start of flat part of Hue range
Definition: PerfectlyClearAdapter.cs:430
LOAD_ERROR_UNSUPPORTED
@ LOAD_ERROR_UNSUPPORTED
Error: unsupported file.
Definition: PFCImageFile.h:25
PerfectlyClearAdapter.PFCFBFACEINFO.rightEye
PFCPOINT rightEye
Point of right eye in detected face.
Definition: PerfectlyClearAdapter.cs:47
PerfectlyClearAdapter.PerfectlyClear.PFCIMAGEPROFILE.RE_Status
PFCRE_STATUS RE_Status
Status code for Red Eye pre-calc analysis.
Definition: PerfectlyClearAdapter.cs:732
PerfectlyClearAdapter.PFCFACERECT.FAE1
int FAE1
Internal data for Face Aware Exposure.
Definition: PerfectlyClearAdapter.cs:82
SKINTONINGTYPE_FOUNDATION
@ SKINTONINGTYPE_FOUNDATION
Adjust skin to user defined foundation color.
Definition: PerfectlyClearPro.h:327
PerfectlyClearAdapter.PerfectlyClear.Apply
unsafe PFCAPPLYSTATUS Apply(ref PFCImageFile imgfile)
Apply correction.
Definition: PerfectlyClearAdapter.cs:1216
PerfectlyClearAdapter.PerfectlyClear.SetAddonPath
static void SetAddonPath(string dirPath)
Set path to directory containing runtime add-ons such as .looks file(s) This enables searching for ad...
Definition: PerfectlyClearAdapter.cs:2234
PerfectlyClearAdapter.PFCFBPARAM
Structure encapsulating Face Beautification parameters.
Definition: PerfectlyClearAdapter.cs:493
SKINTONINGTYPE_TAN
@ SKINTONINGTYPE_TAN
Darkens skin, makes it look naturally tanned.
Definition: PerfectlyClearPro.h:326
SKINTONINGTYPE_WARM
@ SKINTONINGTYPE_WARM
Warms skin tone.
Definition: PerfectlyClearPro.h:325
CALC_FAEHISPEED
@ CALC_FAEHISPEED
Use Fast mode of Face Aware Exposure pre-calculations.
Definition: PerfectlyClearPro.h:170
PerfectlyClearAdapter.PFCPARAM.nr
PFCNRPARAM nr
Noise reduction corrections.
Definition: PerfectlyClearAdapter.cs:662
PerfectlyClearAdapter.PFCRECT
Struct defining a rectangle.
Definition: PerfectlyClearAdapter.cs:28
HIGH_DEFINITION
@ HIGH_DEFINITION
Optimized to bring out more details in the shadows, more details in the highlights,...
Definition: PerfectlyClearPro.h:276
PerfectlyClearAdapter.PFCV3PARAM.iDynamic
int iDynamic
Dynamic correction strength 0 .. 100.
Definition: PerfectlyClearAdapter.cs:633
PFC_PixelFormat64bppARGB
@ PFC_PixelFormat64bppARGB
Definition: PerfectlyClearPro.h:108
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor2
SELECTIVECOLOR selectiveColor2
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:483
PerfectlyClearAdapter.PFCFACERECT
Class defining face attributes from FAE.
Definition: PerfectlyClearAdapter.cs:67
PerfectlyClearAdapter.TINTCORRECTION
TINTCORRECTION
Enumeration defining different abnormal tint analysis mode.
Definition: PerfectlyClearAdapter.cs:343
PerfectlyClearAdapter.PFCV3PARAM.iFinishContrast
int iFinishContrast
Contrast correction amount.
Definition: PerfectlyClearAdapter.cs:625
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, int ISO, string CameraModel, bool bFastFAE)
Performs auto correction.
Definition: PerfectlyClearAdapter.cs:1380
PFC_FB_NOTENABLED
@ PFC_FB_NOTENABLED
1 Feature not enabled
Definition: PerfectlyClearPro.h:366
SKINTONINGTYPE_PALE
@ SKINTONINGTYPE_PALE
Makes skin look lighter and more pale.
Definition: PerfectlyClearPro.h:324
PerfectlyClearAdapter.SKINTONINGTYPE
SKINTONINGTYPE
Enumeration defining type of Skin Toning correction.
Definition: PerfectlyClearAdapter.cs:409
PerfectlyClearAdapter.PerfectlyClear.AbnormalTintDetected
bool AbnormalTintDetected(TINTCORRECTION eTintMethod)
Query if Abnormal Tint detected.
Definition: PerfectlyClearAdapter.cs:1905
PerfectlyClearAdapter.AGGRESSIVENESS.CONSERVATIVE
@ CONSERVATIVE
Less aggressive in exposure correction.
PerfectlyClearAdapter.CONTRASTMODE
CONTRASTMODE
Enumeration defining contrast mode.
Definition: PerfectlyClearAdapter.cs:367
PerfectlyClearAdapter.ADPTRRETURNCODE.WRONG_FORMAT
@ WRONG_FORMAT
Image source in format not supported by this version of API.
BIAS_AVERAGE_PREFERENCE
@ BIAS_AVERAGE_PREFERENCE
For average usage, corresponds to "Normal" in PfC Products.
Definition: PerfectlyClearPro.h:299
PFCFEATURE
PFCFEATURE
ENUM controlling types of calculations at the pre-calculation stage.
Definition: PerfectlyClearPro.h:162
PerfectlyClearAdapter.PFCV3PARAM.iFinishSaturation
int iFinishSaturation
Saturation correction amount.
Definition: PerfectlyClearAdapter.cs:623
PerfectlyClearAdapter.PFCCOREPARAM.iVibrancy
int iVibrancy
Degree of color vibrancy. This value will only be use when bVibrancy is TRUE. Very large values can p...
Definition: PerfectlyClearAdapter.cs:447
PFC_NR_MISC_ERROR
@ PFC_NR_MISC_ERROR
6 General error
Definition: PerfectlyClearPro.h:347
PerfectlyClearAdapter.DP2PARAM.iContrast
int iContrast
-100 .. 100
Definition: PerfectlyClearAdapter.cs:649
PerfectlyClearAdapter.PFCV3PARAM.iFinishPositiveContrast
int iFinishPositiveContrast
Positive Contrast correction amount.
Definition: PerfectlyClearAdapter.cs:626
PerfectlyClearAdapter.PFCCOREPARAM.bAbnormalTintRemoval
bool bAbnormalTintRemoval
Set to true to enable Abnormal Tint Removal. Recommended default is FALSE.
Definition: PerfectlyClearAdapter.cs:442
APPLY_INVALIDLICENSE
@ APPLY_INVALIDLICENSE
-6 Invalid License or validation failed
Definition: PerfectlyClearPro.h:399
PRESET_IAUTO_21
@ PRESET_IAUTO_21
The iAuto you love plus newly (2021) tuned settings for sharper images, accurate skin correction,...
Definition: PerfectlyClearPro.h:189
PerfectlyClearAdapter.PFCNRPARAM.bEnabled
bool bEnabled
Set to TRUE to enable noise removal.
Definition: PerfectlyClearAdapter.cs:538
PerfectlyClearAdapter.PFCCOREPARAM.eDCFMode
DCFMODE eDCFMode
Select different class of DCF.
Definition: PerfectlyClearAdapter.cs:468
PerfectlyClearAdapter.PerfectlyClear.FAEFaceCount
int FAEFaceCount()
Returns the count of the faces recogniced by FAE.
Definition: PerfectlyClearAdapter.cs:2138
PerfectlyClearAdapter.PFCFACERECT.rcEyeL
PFCRECT rcEyeL
Specifies the bounding rectangle of the left eye.
Definition: PerfectlyClearAdapter.cs:69
PerfectlyClearAdapter.PFCRECT.width
int width
width of this rect.
Definition: PerfectlyClearAdapter.cs:31
PRESET_IAUTO_2019_RE
@ PRESET_IAUTO_2019_RE
iAuto 2019 with Red Eye correciton enabled
Definition: PerfectlyClearPro.h:188
PerfectlyClearAdapter.PFCFBPARAM.eSkinToningType
SKINTONINGTYPE eSkinToningType
See enum definition of SKINTONINGTYPE.
Definition: PerfectlyClearAdapter.cs:525
PerfectlyClearAdapter.PFCCOREPARAM
Structure encapsulating the CORE processing parameters.
Definition: PerfectlyClearAdapter.cs:440
PerfectlyClearAdapter.PFCFACERECT.blinkLevel
int blinkLevel
Indicates the presence of a blink.
Definition: PerfectlyClearAdapter.cs:75
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:1007
PerfectlyClearAdapter.PFCCOREPARAM.fDCF
float fDCF
Scale value to control intensity of Digital Color Fidelity correction. Range 0.0 to 1....
Definition: PerfectlyClearAdapter.cs:469
PFC_FB_NOT_EXECUTED
@ PFC_FB_NOT_EXECUTED
9 Not executed
Definition: PerfectlyClearPro.h:374
PFC_RE_GEN_ERROR
@ PFC_RE_GEN_ERROR
4 General error
Definition: PerfectlyClearPro.h:384
APPLY_WASM_INVALID_DOMAIN
@ APPLY_WASM_INVALID_DOMAIN
-7 Wrong domain for WASM certificate
Definition: PerfectlyClearPro.h:400
PerfectlyClearAdapter.LIPSHARPENTYPE
LIPSHARPENTYPE
Enumeration defining Lip Sharpening mode.
Definition: PerfectlyClearAdapter.cs:419
PerfectlyClearAdapter.PFCFBPARAM.colorBlush
uint colorBlush
Blush color AARRGGBB default 0xFFFD7171 ({253, 113, 113})
Definition: PerfectlyClearAdapter.cs:532
CALC_SCENE_DETECTION
@ CALC_SCENE_DETECTION
Calculate Scene Detection.
Definition: PerfectlyClearPro.h:173
PerfectlyClearAdapter.PFCFBPARAM.bSlim
bool bSlim
Set to TRUE to enable face slimming.
Definition: PerfectlyClearAdapter.cs:509
PerfectlyClearAdapter.PerfectlyClear.PFCENGINE
Struct defining an PFC engine instance.
Definition: PerfectlyClearAdapter.cs:704
PerfectlyClearAdapter.PFCCOREMask.transparency
float transparency
overall transparency applied to the whole mask (strength 100 means transparency 0....
Definition: PerfectlyClearAdapter.cs:582
PerfectlyClearAdapter.PFCV3PARAM.bPreprocessEV
bool bPreprocessEV
Enable EV correction (ImageAmbulance)
Definition: PerfectlyClearAdapter.cs:603
PerfectlyClearAdapter.PFCSCENEDESCRIPTION
Struct describing Scene information.
Definition: PerfectlyClearAdapter.cs:687
PerfectlyClearAdapter.PFCCOREPARAM.eBiasMode
BIASMODE eBiasMode
Skin and depth bias control. Recommended value is BIAS_AVERAGE_PREFERENCE, unless you are printing to...
Definition: PerfectlyClearAdapter.cs:452
PerfectlyClearAdapter.PerfectlyClear.ApplyStrengthToParam
void ApplyStrengthToParam(int strength)
Apply overall strength to parameters, same as Strength in Perfecly Clear products Adjusts the paramet...
Definition: PerfectlyClearAdapter.cs:1915
PerfectlyClearAdapter.ADPTRRETURNCODE.INTERNALERROR
@ INTERNALERROR
Internal errors.
PerfectlyClearAdapter.PFCFBPARAM.iLipSharpen
int iLipSharpen
Lip sharpening level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:527
PerfectlyClearAdapter.PFCFBPARAM.bSkinToning
bool bSkinToning
Set to TRUE to enable skin toning.
Definition: PerfectlyClearAdapter.cs:522
PerfectlyClearAdapter.DP2PARAM.iDeltaB
int iDeltaB
-100 .. 100
Definition: PerfectlyClearAdapter.cs:647
PerfectlyClearAdapter.PerfectlyClear.Apply
unsafe PFCAPPLYSTATUS Apply(ref PFCImageFile imgfile, int iOpacity)
Apply correction.
Definition: PerfectlyClearAdapter.cs:1284
PerfectlyClearAdapter.PFCV3PARAM.iDeltaB
int iDeltaB
Delta B correction amount.
Definition: PerfectlyClearAdapter.cs:630
PerfectlyClearAdapter.PFCFBPARAM.bCatchLight
bool bCatchLight
Set to TRUE to enable catchlight removal.
Definition: PerfectlyClearAdapter.cs:513
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, ref Bitmap bmds, PFCFEATURE feature, int ISO, string CameraModel)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:1121
PerfectlyClearAdapter.PFCCOREPARAM.iMaxStrength
int iMaxStrength
Use this value to limit the maximum Exposure to be applied on the Automatic Exposure Strength Selecti...
Definition: PerfectlyClearAdapter.cs:461
PerfectlyClearAdapter.PFCFACERECT.rcMouth
PFCRECT rcMouth
Specifies the bounding rectangle of the mouth.
Definition: PerfectlyClearAdapter.cs:71
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref PFCImageFile imgfile)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1355
PerfectlyClearAdapter.PFCCOREPARAM.fSharpenScale
float fSharpenScale
Sharpening intensity. This value controls how much sharpening to be applied. Range 0....
Definition: PerfectlyClearAdapter.cs:457
LIPSHARPENTYPE_MEDIUM
@ LIPSHARPENTYPE_MEDIUM
Stronger sharpening. Details are more pronounced.
Definition: PerfectlyClearPro.h:334
CALC_NR
@ CALC_NR
Calculates for Perfectly Clear Noise Removal.
Definition: PerfectlyClearPro.h:164
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor7
SELECTIVECOLOR selectiveColor7
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:488
PFC_CORE_CLIPARTIMAGE
@ PFC_CORE_CLIPARTIMAGE
7 Image skipped due AI Clipart detection
Definition: PerfectlyClearPro.h:360
PFC_FB_CANCELLED
@ PFC_FB_CANCELLED
4 Process cancelled
Definition: PerfectlyClearPro.h:369
BIAS_AUTO
@ BIAS_AUTO
Apply auto calculated bias mode and strength.
Definition: PerfectlyClearPro.h:302
PerfectlyClearAdapter.PFCFBPARAM.iBlush
int iBlush
Blush level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:530
PerfectlyClearAdapter.PerfectlyClear.GetFaceInfo
bool GetFaceInfo(ref PFCFBFACEINFO info, int index)
Get face information.
Definition: PerfectlyClearAdapter.cs:1885
PerfectlyClearAdapter.PFCFACERECT.ptEyeR
PFCPOINT ptEyeR
Specifies the x,y coordinates of the right eye, in fixed-point arithmetics (10 bit precision).
Definition: PerfectlyClearAdapter.cs:73
PerfectlyClearAdapter.PFCFACERECT.FAE3
int FAE3
Internal data for Face Aware Exposure.
Definition: PerfectlyClearAdapter.cs:84
PerfectlyClearAdapter.PFCFACERECT.confidence
int confidence
A numerical parameter describing the confidence attributed by the detection algorithm to each face.
Definition: PerfectlyClearAdapter.cs:79
PerfectlyClearAdapter.PFCFBFACEINFO1
Legacy structure defining face area detected from the SFB library.
Definition: PerfectlyClearAdapter.cs:37
APPLY_LOOKS_MISSING
@ APPLY_LOOKS_MISSING
-12 tried to apply a LUT but the LUTs file was not found
Definition: PerfectlyClearPro.h:405
PerfectlyClearAdapter.PFCFACERECT.rcEyeR
PFCRECT rcEyeR
Specifies the bounding rectangle of the right eye.
Definition: PerfectlyClearAdapter.cs:70
PerfectlyClearAdapter.PFCFACERECT.FAE2
int FAE2
Internal data for Face Aware Exposure.
Definition: PerfectlyClearAdapter.cs:83
PRESET_BEAUTIFY
@ PRESET_BEAUTIFY
Beautify - provides a good default set of corrections for portratis and other photos of people....
Definition: PerfectlyClearPro.h:182
PerfectlyClearAdapter.PFCV3PARAM.iFinishShadows
int iFinishShadows
Shadows correction amount.
Definition: PerfectlyClearAdapter.cs:620
PerfectlyClearAdapter.PFCCOREPARAM.iSkintoneStrengthLut
int iSkintoneStrengthLut
Strength of lut correction 0 .. 100 applied with input skintone correction.
Definition: PerfectlyClearAdapter.cs:474
PerfectlyClearAdapter.PFCPARAM.layer2
PFCV3PARAM layer2
params on layers 2 - fiinishing
Definition: PerfectlyClearAdapter.cs:667
PerfectlyClearAdapter.PFCNRPARAM
Structure encapsulating Noise Removal parameters.
Definition: PerfectlyClearAdapter.cs:537
BIAS_DONT_BOTHER
@ BIAS_DONT_BOTHER
Reserved, never use.
Definition: PerfectlyClearPro.h:301
PerfectlyClearAdapter.PFCFBPARAM.eLipSharpenType
LIPSHARPENTYPE eLipSharpenType
See definition of LIPSHARPENTYPE.
Definition: PerfectlyClearAdapter.cs:528
PFC_FB_WARNING
@ PFC_FB_WARNING
2 Warning: face not detected
Definition: PerfectlyClearPro.h:367
PerfectlyClearAdapter.PerfectlyClear.AutoCorrect
int AutoCorrect(ref Bitmap bm, ref Bitmap bmds, string pathPreset, int ISO, string CameraModel, bool bFastFAE)
Overload method for auto correction.
Definition: PerfectlyClearAdapter.cs:1722
PerfectlyClearAdapter.PFCNRPARAM.iStrengthOffset
int iStrengthOffset
Offset to recommended level of noise removal strength. Range -5 to 5.
Definition: PerfectlyClearAdapter.cs:547
PerfectlyClearAdapter.PFCRE_STATUS
PFCRE_STATUS
Enumeration defining status of Red Eye pre-calculation.
Definition: PerfectlyClearAdapter.cs:311
PFC_RE_SUCCESS
@ PFC_RE_SUCCESS
0 Success
Definition: PerfectlyClearPro.h:380
PerfectlyClearAdapter.PFCCORE_STATUS
PFCCORE_STATUS
Enumeration defining status of Core pre-calculation.
Definition: PerfectlyClearAdapter.cs:274
PFC_PixelFormat32bppABGR
@ PFC_PixelFormat32bppABGR
Definition: PerfectlyClearPro.h:80
PerfectlyClearAdapter.PFCFBFACEINFO.PFCFBFACEINFO
PFCFBFACEINFO()
Class constructor.
Definition: PerfectlyClearAdapter.cs:51
PerfectlyClearAdapter.PFCPARAM.dp2
DP2PARAM dp2
DP2 param.
Definition: PerfectlyClearAdapter.cs:671
PerfectlyClearAdapter.PFCFBPARAM.iSkinToning
int iSkinToning
Skin Toning level. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:523
PerfectlyClearAdapter.PFCCOREPARAM.iBlackEnhancement
int iBlackEnhancement
Set luminance threshold for Noise Management. Range 0 to 25.
Definition: PerfectlyClearAdapter.cs:445
PerfectlyClearAdapter.PFCV3PARAM.iOutLUTcontrast
int iOutLUTcontrast
lutOutput contrast -100 .. 100
Definition: PerfectlyClearAdapter.cs:636
PFC_NR_NOTENABLED
@ PFC_NR_NOTENABLED
1 Feature not enabled
Definition: PerfectlyClearPro.h:342
LOAD_OK
@ LOAD_OK
Success.
Definition: PFCImageFile.h:23
PerfectlyClearAdapter.PFCCOREMask.type
PFCCORE_MASK_TYPE type
Mask type.
Definition: PerfectlyClearAdapter.cs:574
PRESET_VIVID
@ PRESET_VIVID
Vivid - good for landscapes and other general photography. This is in the 'Perfectly Clear Essentials...
Definition: PerfectlyClearPro.h:185
PerfectlyClearAdapter.PFCCOREPARAM.selectiveColor4
SELECTIVECOLOR selectiveColor4
Definition of range of Selective Color correction
Definition: PerfectlyClearAdapter.cs:485
PerfectlyClearAdapter.SELECTIVECOLOR.r
int r
start of Hue range ramp
Definition: PerfectlyClearAdapter.cs:429
PerfectlyClearAdapter.PFCV3PARAM.iFinishBlacks
int iFinishBlacks
Blacks correction amount.
Definition: PerfectlyClearAdapter.cs:619
PerfectlyClearAdapter.PFCFACERECT.heightImage
int heightImage
image height
Definition: PerfectlyClearAdapter.cs:86
PerfectlyClearAdapter.PFCCOREPARAM.bSelectiveColor
bool bSelectiveColor
Apply Selective Color HSL correction.
Definition: PerfectlyClearAdapter.cs:480
PerfectlyClearAdapter.PFCCOREPARAM.bEnabled
bool bEnabled
Set to true to enable the entire Core correction.
Definition: PerfectlyClearAdapter.cs:441
PerfectlyClearAdapter.PFCImageFile.PFC_FILETYPE
PFC_FILETYPE
ENUM to set the filetype of files / buffers.
Definition: PerfectlyClearAdapter.cs:2572
PFCImageFile
PFCImageFile Class to encapsulate file handling.
Definition: PFCImageFile.h:72
PerfectlyClearAdapter.PFCImageFile
PFCImageFile Class to encapsulate file handling.
Definition: PerfectlyClearAdapter.cs:2526
PFC_FB_ANALYSIS_FAILED
@ PFC_FB_ANALYSIS_FAILED
7 The face analysis did not complete successfully
Definition: PerfectlyClearPro.h:372
PerfectlyClearAdapter.PFCV3PARAM.iDynamicWB
int iDynamicWB
Strength of color component of Dynamic correction 0 .. 100.
Definition: PerfectlyClearAdapter.cs:634
PerfectlyClearAdapter.PerfectlyClear.EnumFAEFaceRect
unsafe bool EnumFAEFaceRect(ref PFCFACERECT rect)
Allows the user to iterate over the known faces to FAE.
Definition: PerfectlyClearAdapter.cs:2118
PerfectlyClearAdapter.SKINSMOOTHTYPE
SKINSMOOTHTYPE
Enumeration defining types of Skin Smoothing correction.
Definition: PerfectlyClearAdapter.cs:401
PerfectlyClearAdapter.PFCFBPARAM.bDeFlash
bool bDeFlash
Set to TRUE to enable deflash.
Definition: PerfectlyClearAdapter.cs:511
PerfectlyClearAdapter.PFCCOREPARAM.iHighlightPreservation
int iHighlightPreservation
Amount of Highlight Preservation to apply. Range 0 to 100.
Definition: PerfectlyClearAdapter.cs:454
APPLY_WASM_EXPIRED_CERTIFICATE
@ APPLY_WASM_EXPIRED_CERTIFICATE
-10 WASM certificate has expired
Definition: PerfectlyClearPro.h:403
PerfectlyClearAdapter.PFCSTATUS
Struct PFCSTATUS Process status of all sub sectors.
Definition: PerfectlyClearAdapter.cs:676
PFC_REJECT_NONE
@ PFC_REJECT_NONE
Disable image rejection.
Definition: PerfectlyClearPro.h:412
PerfectlyClearAdapter.PFCPOINT
Struct defining a point.
Definition: PerfectlyClearAdapter.cs:20
PerfectlyClearAdapter.PFCPARAM.layer1
PFCV3PARAM layer1
params on layers 1 - bottom/outside, 2 - fiinishing
Definition: PerfectlyClearAdapter.cs:666
PFC_FB_CREATE_ENGINE_FAILED
@ PFC_FB_CREATE_ENGINE_FAILED
6 Unable to create SFB Engine object for processing
Definition: PerfectlyClearPro.h:371
PerfectlyClearAdapter.PFCFBFACEINFO.face
PFCRECT face
Bounding rectangle of detected face.
Definition: PerfectlyClearAdapter.cs:48
PerfectlyClearAdapter.PerfectlyClear.ReadScenePreset
int ReadScenePreset(ref PFCPARAM param, int scene)
Fill param for the scene from the engine with previously loaded scene presets with LoadScenePresets.
Definition: PerfectlyClearAdapter.cs:2202
PerfectlyClearAdapter.PerfectlyClear
Definition: PerfectlyClearAdapter.cs:701
PFC_RE_NO_MEMORY
@ PFC_RE_NO_MEMORY
6 Insufficient memory
Definition: PerfectlyClearPro.h:386
APPLY_NOSOURCE
@ APPLY_NOSOURCE
-4 Pointer pImage is NULL, source image missing
Definition: PerfectlyClearPro.h:397
PerfectlyClearAdapter.PFCFBPARAM.eSmoothType
SKINSMOOTHTYPE eSmoothType
See enum definition of SKINSMOOTHTYPE.
Definition: PerfectlyClearAdapter.cs:498
AI_COMPOSITE
@ AI_COMPOSITE
Loads composite detection model, requiring the file composite.pnn
Definition: PerfectlyClearPro.h:1110
PerfectlyClearAdapter.PFCCOREPARAM.eTintMode
TINTCORRECTION eTintMode
ENUM value defined in TINTCORRECTION. It sets the aggressiveness of Tint Removal.
Definition: PerfectlyClearAdapter.cs:443
PerfectlyClearAdapter.PFCCOREMask.feather
float feather
relative length of gradient, from where it starts (1.0) to where it is 0.0,
Definition: PerfectlyClearAdapter.cs:580
TINTCORRECT_CONSERVATIVE
@ TINTCORRECT_CONSERVATIVE
Priority on minimum false positive detection.
Definition: PerfectlyClearPro.h:268
BIAS_ASIAN_PREFERENCE
@ BIAS_ASIAN_PREFERENCE
Fine tuned for Asian skin tone.
Definition: PerfectlyClearPro.h:298
PerfectlyClearAdapter.PerfectlyClear.Calc
unsafe ADPTRRETURNCODE Calc(ref Bitmap bm, PFCFEATURE feature, int ISO, string CameraModel, PFCREJECTOPTION rejectOption=PFCREJECTOPTION.PFC_REJECT_CLIPART)
Overload method for precalc analysis.
Definition: PerfectlyClearAdapter.cs:1021
CALC_CARTOON_DETECTOR
@ CALC_CARTOON_DETECTOR
Calculate legacy cartoon detector.
Definition: PerfectlyClearPro.h:171
PerfectlyClearAdapter.PerfectlyClear.LoadScenePresetsFromStream
int LoadScenePresetsFromStream(FileStream fs, int groupUUID=0, int *arrProfileUUID=null, int arrProfileUUIDLen=0)
Read a Scene preset from a file stream.
Definition: PerfectlyClearAdapter.cs:1837
PerfectlyClearAdapter.PerfectlyClear.ReadPresetsFromStream
int ReadPresetsFromStream(FileStream fs)
Read a preset from a file stream.
Definition: PerfectlyClearAdapter.cs:1795
AI_COLOR
@ AI_COLOR
Loads AI White Balance color corrections model, requiring the file aicolor.pnn
Definition: PerfectlyClearPro.h:1112
PerfectlyClearAdapter.PerfectlyClear.GetScene
int GetScene(int *version)
Get scene detection label from profile obtained with Pfc.Calc For this to work you need to pass AI_SC...
Definition: PerfectlyClearAdapter.cs:2213
APPLY_ERROR_ENGINE_MISSING
@ APPLY_ERROR_ENGINE_MISSING
-2 Pointer pEngine is NULL
Definition: PerfectlyClearPro.h:395
PerfectlyClearAdapter.ADPTRRETURNCODE.WARNING
@ WARNING
Some warnings during processing.
PFC_FB_FUNCTION_ERROR
@ PFC_FB_FUNCTION_ERROR
5 Unable to locate function in the SFBEngine library
Definition: PerfectlyClearPro.h:370
PerfectlyClearAdapter.PFCFBPARAM.bEyeCirc
bool bEyeCirc
Set to TRUE to enable eye circle removal.
Definition: PerfectlyClearAdapter.cs:503
CALC_NOTINTCALC
@ CALC_NOTINTCALC
Skip pre-calculations on Abnormal Tint Correction during Core pre-calculations.
Definition: PerfectlyClearPro.h:168
PFC_CORE_BELOWMINSIZE
@ PFC_CORE_BELOWMINSIZE
6 Image skipped, too small ( < 32 pixels )
Definition: PerfectlyClearPro.h:359
PerfectlyClearAdapter.PerfectlyClear.GetCategorizationEngineInfo
bool GetCategorizationEngineInfo(int *groupUUID, int *arrProfileUUID, int *arrProfileUUIDLen)
Get loaded (with PFC_LoadAIEngine) categorization model info Call first with arrProfileUUID to get ar...
Definition: PerfectlyClearAdapter.cs:2226
PerfectlyClearAdapter.PFCFACERECT.ptEyeL
PFCPOINT ptEyeL
Specifies the x,y coordinates of the left eye, in fixed-point arithmetics (10 bit precision).
Definition: PerfectlyClearAdapter.cs:72
PerfectlyClearAdapter.PFCV3PARAM.lutInputCorrective
PFC3DLutInfo lutInputCorrective
LUT data to apply.
Definition: PerfectlyClearAdapter.cs:609
PerfectlyClearAdapter.PFCV3PARAM.iFinishTint
int iFinishTint
Tint correction amount.
Definition: PerfectlyClearAdapter.cs:617
PFC_RE_NOT_SUPPORTED
@ PFC_RE_NOT_SUPPORTED
8 Not supported
Definition: PerfectlyClearPro.h:388
PerfectlyClearAdapter.PFCImageFile.CompressImageBuffer
MemoryStream CompressImageBuffer(PFC_FILETYPE type, int jpegQuality=92, bool bConvertToOriginalColorSpace=true, bool bEmbedOriginalMetadata=true)
Write image data to MemoryStream.
Definition: PerfectlyClearAdapter.cs:2761
PerfectlyClearAdapter.PFCCOREMask.centerY
float centerY
Y of center.
Definition: PerfectlyClearAdapter.cs:576
PerfectlyClearAdapter
Definition: PerfectlyClearAdapter.cs:16