Beispiel #1
0
            public static PicPixel CreatePicPixel(int nW, int nH)
            {
                PicPixel pPix = new PicPixel();

                pPix.pixel  = Marshal.AllocHGlobal(nW * nH);
                pPix.width  = nW;
                pPix.height = nH;
                return(pPix);
            }
Beispiel #2
0
 public static void DeletePicPixel(ref PicPixel pPicPixel)
 {
     if (pPicPixel != null)
     {
         Marshal.FreeHGlobal(pPicPixel.pixel);
         pPicPixel.pixel  = IntPtr.Zero;
         pPicPixel.width  = 0;
         pPicPixel.height = 0;
     }
     pPicPixel = null;
 }
Beispiel #3
0
        private void GetGrayPixel(PicPixel pPix, Bitmap bmCur)
        {
            int nW = pPix.width;
            int nH = pPix.height;

            using (Bitmap bmTemp = WinCall.BitmapScale(bmCur, nW, nH))
            {
                using (Bitmap bmGrapy = WinCall.BitmapConvetGray(bmTemp))
                {
                    Rectangle     rect     = new Rectangle(0, 0, nW, nH);
                    BitmapData    dataGray = bmGrapy.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
                    System.IntPtr ptrGray  = dataGray.Scan0;
                    WinCall.CopyMemory(pPix.pixel, ptrGray, nW * nH);
                    bmGrapy.UnlockBits(dataGray);
                }
            }
        }
Beispiel #4
0
 public void Dispose()
 {
     if (handleLib != IntPtr.Zero)
     {
         HWRelease(ref handleLib);
         handleLib = IntPtr.Zero;
     }
     HWReleaseD();
     if (idPhotoData != null)
     {
         PicPixel.DeletePicPixel(ref idPhotoData);
     }
     if (livePhotoData != null)
     {
         PicPixel.DeletePicPixel(ref livePhotoData);
     }
     ClearPhoto(ref bmLivePhoto);
     ClearPhoto(ref bmFaceLivePhoto);
 }
Beispiel #5
0
        public bool InitLib()
        {
            string   strCurdir = Application.StartupPath;
            HWRESULT hRes      = HWInitialD(strCurdir);

            if (S_OK != hRes)
            {
                return(false);
            }
            hRes = HWInitial(ref handleLib, strCurdir);
            bool bInit = (S_OK == hRes);

            if (bInit)
            {
                idPhotoData   = PicPixel.CreatePicPixel(ID_PHOTO_WID, ID_PHOTO_HEI);
                livePhotoData = PicPixel.CreatePicPixel(LIVE_PHOTO_WID, LIVE_PHOTO_HEI);
            }
            return(bInit);
        }