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); }
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; }
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); } } }
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); }
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); }